~ubuntu-branches/ubuntu/hardy/coq-doc/hardy

« back to all changes in this revision

Viewing changes to faq.html

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2004-09-18 13:28:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040918132822-ees5mb8qmzd6a0fw
Tags: 8.0pl1.0-1
* Added the Coq faq, moved the tutorial to the root directory and added
  doc-base files for both, closes: #272204.
* Set dh_compat to level 4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 
2
            "http://www.w3.org/TR/REC-html40/loose.dtd">
 
3
<HTML>
 
4
<HEAD><TITLE></TITLE>
 
5
 
 
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 
7
<META name="GENERATOR" content="hevea 1.07">
 
8
</HEAD>
 
9
<BODY >
 
10
<!--HEVEA command line is: hevea -fix -nosymb main.v.tex -->
 
11
<!--HTMLHEAD-->
 
12
<!--ENDHTML-->
 
13
<!--PREFIX <ARG ></ARG>-->
 
14
<!--CUT DEF section 1 -->
 
15
 
 
16
 
 
17
 
 
18
<BR>
 
19
<BR>
 
20
 
 
21
 
 
22
 
 
23
<H1 ALIGN=center>Coq Version 8.0 for the Clueless<BR>
 
24
<FONT SIZE=4>(</FONT><A HREF="#lastquestion"><FONT SIZE=4>174</FONT></A><FONT SIZE=4>
 
25
  Hints)
 
26
</FONT></H1>
 
27
 
 
28
<H3 ALIGN=center>Hugo Herbelin &nbsp;&nbsp;Florent Kirchner &nbsp;&nbsp;Benjamin Monate &nbsp;&nbsp;Julien Narboux</H3>
 
29
 
 
30
<BLOCKQUOTE><B>Abstract: </B>
 
31
This note intends to provide an easy way to get acquainted with the
 
32
<FONT COLOR=navy>Coq</FONT> theorem prover. It tries to formulate appropriate answers
 
33
to some of the questions any newcomers will face, and to give
 
34
pointers to other references when possible.
 
35
</BLOCKQUOTE>
 
36
<!--TOC section Table of Contents-->
 
37
 
 
38
<H2>Table of Contents</H2><!--SEC END -->
 
39
 
 
40
<UL><LI>
 
41
<A HREF="#htoc1">1&nbsp;&nbsp;Introduction</A>
 
42
<LI><A HREF="#htoc2">2&nbsp;&nbsp;Presentation</A>
 
43
<UL>
 
44
<UL><LI>
 
45
<A HREF="#htoc3">1&nbsp;&nbsp;What is <FONT COLOR=navy>Coq</FONT>?</A>
 
46
<LI><A HREF="#htoc4">2&nbsp;&nbsp;Did you really need to name it like that?</A>
 
47
<LI><A HREF="#htoc5">3&nbsp;&nbsp;Is <FONT COLOR=navy>Coq</FONT> a theorem prover?</A>
 
48
<LI><A HREF="#htoc6">4&nbsp;&nbsp;What are the other theorem provers?</A>
 
49
<LI><A HREF="#htoc7">5&nbsp;&nbsp;Who do I have to trust when I see a proof checked by Coq?</A>
 
50
<LI><A HREF="#htoc8">6&nbsp;&nbsp;Where can I find information about the theory behind <FONT COLOR=navy>Coq</FONT>?</A>
 
51
<LI><A HREF="#htoc9">7&nbsp;&nbsp;How can I use <FONT COLOR=navy>Coq</FONT> to prove programs?</A>
 
52
<LI><A HREF="#htoc10">8&nbsp;&nbsp;How many <FONT COLOR=navy>Coq</FONT> users are there?</A>
 
53
<LI><A HREF="#htoc11">9&nbsp;&nbsp;How old is <FONT COLOR=navy>Coq</FONT>?</A>
 
54
<LI><A HREF="#htoc12">10&nbsp;&nbsp;What are the <FONT COLOR=navy>Coq</FONT>-related tools?</A>
 
55
<LI><A HREF="#htoc13">11&nbsp;&nbsp;What are the high-level tactics of <FONT COLOR=navy>Coq</FONT></A>
 
56
<LI><A HREF="#htoc14">12&nbsp;&nbsp;What are the main libraries available for <FONT COLOR=navy>Coq</FONT></A>
 
57
<LI><A HREF="#htoc15">13&nbsp;&nbsp;What are the academic applications for <FONT COLOR=navy>Coq</FONT>?</A>
 
58
<LI><A HREF="#htoc16">14&nbsp;&nbsp;What are the industrial applications for <FONT COLOR=navy>Coq</FONT>?</A>
 
59
</UL>
 
60
</UL>
 
61
<LI><A HREF="#htoc17">3&nbsp;&nbsp;Documentation</A>
 
62
<UL>
 
63
<UL><LI>
 
64
<A HREF="#htoc18">15&nbsp;&nbsp;Where can I find documentation about <FONT COLOR=navy>Coq</FONT>?</A>
 
65
<LI><A HREF="#htoc19">16&nbsp;&nbsp;Where can I find this FAQ on the web?</A>
 
66
<LI><A HREF="#htoc20">17&nbsp;&nbsp;How can I submit suggestions / improvements / additions for this FAQ?</A>
 
67
<LI><A HREF="#htoc21">18&nbsp;&nbsp;Is there any mailing list about <FONT COLOR=navy>Coq</FONT>?</A>
 
68
<LI><A HREF="#htoc22">19&nbsp;&nbsp;Where can I find an archive of the list?</A>
 
69
<LI><A HREF="#htoc23">20&nbsp;&nbsp;How can I be kept informed of new releases of <FONT COLOR=navy>Coq</FONT>?</A>
 
70
<LI><A HREF="#htoc24">21&nbsp;&nbsp;Is there any book about <FONT COLOR=navy>Coq</FONT>?</A>
 
71
<LI><A HREF="#htoc25">22&nbsp;&nbsp;Where can I find some <FONT COLOR=navy>Coq</FONT> examples?</A>
 
72
<LI><A HREF="#htoc26">23&nbsp;&nbsp;How can I report a bug?</A>
 
73
</UL>
 
74
</UL>
 
75
<LI><A HREF="#htoc27">4&nbsp;&nbsp;Installation</A>
 
76
<UL>
 
77
<UL><LI>
 
78
<A HREF="#htoc28">24&nbsp;&nbsp;What is the license of <FONT COLOR=navy>Coq</FONT>?</A>
 
79
<LI><A HREF="#htoc29">25&nbsp;&nbsp;Where can I find the sources of <FONT COLOR=navy>Coq</FONT>?</A>
 
80
<LI><A HREF="#htoc30">26&nbsp;&nbsp;On which platform is <FONT COLOR=navy>Coq</FONT> available?</A>
 
81
</UL>
 
82
</UL>
 
83
<LI><A HREF="#htoc31">5&nbsp;&nbsp;The logic of <FONT COLOR=navy>Coq</FONT></A>
 
84
<UL><LI>
 
85
<A HREF="#htoc32">5.1&nbsp;&nbsp;General</A>
 
86
<UL><LI>
 
87
<A HREF="#htoc33">27&nbsp;&nbsp;What is the logic of <FONT COLOR=navy>Coq</FONT>?</A>
 
88
<LI><A HREF="#htoc34">28&nbsp;&nbsp;Is <FONT COLOR=navy>Coq</FONT>'s logic intuitionistic or classical?</A>
 
89
<LI><A HREF="#htoc35">29&nbsp;&nbsp;Can I define non-terminating programs in <FONT COLOR=navy>Coq</FONT>?</A>
 
90
<LI><A HREF="#htoc36">30&nbsp;&nbsp;How is equational reasoning working in <FONT COLOR=navy>Coq</FONT>?</A>
 
91
</UL>
 
92
<LI><A HREF="#htoc37">5.2&nbsp;&nbsp;Axioms</A>
 
93
<UL><LI>
 
94
<A HREF="#htoc38">31&nbsp;&nbsp;What axioms can be safely added to <FONT COLOR=navy>Coq</FONT>?</A>
 
95
<LI><A HREF="#htoc39">32&nbsp;&nbsp;What standard axioms are inconsistent with <FONT COLOR=navy>Coq</FONT>?</A>
 
96
<LI><A HREF="#htoc40">33&nbsp;&nbsp;What is Streicher's axiom <I>K</I></A>
 
97
<LI><A HREF="#htoc41">34&nbsp;&nbsp;What is proof-irrelevance</A>
 
98
<LI><A HREF="#htoc42">35&nbsp;&nbsp;What about functional extensionality?</A>
 
99
<LI><A HREF="#htoc43">36&nbsp;&nbsp;Is <TT>Prop</TT> impredicative?</A>
 
100
<LI><A HREF="#htoc44">37&nbsp;&nbsp;Is <TT>Set</TT> impredicative?</A>
 
101
<LI><A HREF="#htoc45">38&nbsp;&nbsp;Is <TT>Type</TT> impredicative?</A>
 
102
<LI><A HREF="#htoc46">39&nbsp;&nbsp;I have two proofs of the same proposition. Can I prove they are equal?</A>
 
103
<LI><A HREF="#htoc47">40&nbsp;&nbsp;I have two proofs of an equality statement. Can I prove they are 
 
104
equal?</A>
 
105
<LI><A HREF="#htoc48">41&nbsp;&nbsp;Can I prove that the second components of equal dependent
 
106
pairs are equal?</A>
 
107
</UL>
 
108
<LI><A HREF="#htoc49">5.3&nbsp;&nbsp;Impredicativity</A>
 
109
<UL><LI>
 
110
<A HREF="#htoc50">42&nbsp;&nbsp;Why <TT>injection</TT> does not work on impredicative <TT>Set</TT>?</A>
 
111
<LI><A HREF="#htoc51">43&nbsp;&nbsp;What is a "large inductive definition"?</A>
 
112
</UL>
 
113
</UL>
 
114
<LI><A HREF="#htoc52">6&nbsp;&nbsp;Talkin' with the Rooster</A>
 
115
<UL><LI>
 
116
<A HREF="#htoc53">6.1&nbsp;&nbsp;My goal is ..., how can I prove it?</A>
 
117
<UL><LI>
 
118
<A HREF="#htoc54">44&nbsp;&nbsp;My goal is a conjunction, how can I prove it?</A>
 
119
<LI><A HREF="#htoc55">45&nbsp;&nbsp;My goal contains a conjunction as an hypothesis, how can I use it?</A>
 
120
<LI><A HREF="#htoc56">46&nbsp;&nbsp;My goal is a disjunction, how can I prove it?</A>
 
121
<LI><A HREF="#htoc57">47&nbsp;&nbsp;My goal is an universally quantified statement, how can I prove it?</A>
 
122
<LI><A HREF="#htoc58">48&nbsp;&nbsp;My goal is an existential, how can I prove it?</A>
 
123
<LI><A HREF="#htoc59">49&nbsp;&nbsp;My goal is solvable by some lemma, how can I prove it?</A>
 
124
<LI><A HREF="#htoc60">50&nbsp;&nbsp;My goal contains False as an hypotheses, how can I prove it?</A>
 
125
<LI><A HREF="#htoc61">51&nbsp;&nbsp;My goal is an equality of two convertible terms, how can I prove it?</A>
 
126
<LI><A HREF="#htoc62">52&nbsp;&nbsp;My goal is a <TT>let x := a in ...</TT>, how can I prove it?</A>
 
127
<LI><A HREF="#htoc63">53&nbsp;&nbsp;My goal is a <TT>let (a, ..., b) := c in</TT>, how can I prove it?</A>
 
128
<LI><A HREF="#htoc64">54&nbsp;&nbsp;My goal contains some existential hypotheses, how can I use it?</A>
 
129
<LI><A HREF="#htoc65">55&nbsp;&nbsp;My goal contains some existential hypotheses, how can I use it and decompose my knowledge about this new thing into different hypotheses?</A>
 
130
<LI><A HREF="#htoc66">56&nbsp;&nbsp;My goal is an equality, how can I swap the left and right hand terms?</A>
 
131
<LI><A HREF="#htoc67">57&nbsp;&nbsp;My hypothesis is an equality, how can I swap the left and right hand terms?</A>
 
132
<LI><A HREF="#htoc68">58&nbsp;&nbsp;My goal is an equality, how can I prove it by transitivity?</A>
 
133
<LI><A HREF="#htoc69">59&nbsp;&nbsp;My goal would be solvable using <TT>apply;assumption</TT> if it would not create meta-variables, how can I prove it?</A>
 
134
<LI><A HREF="#htoc70">60&nbsp;&nbsp;My goal is solvable by some lemma within a set of lemmas and I don't want to remember which one, how can I prove it?</A>
 
135
<LI><A HREF="#htoc71">61&nbsp;&nbsp;My goal is one of the hypotheses, how can I prove it?</A>
 
136
<LI><A HREF="#htoc72">62&nbsp;&nbsp;My goal appears twice in the hypotheses and I want to choose which one is used, how can I do it?</A>
 
137
<LI><A HREF="#htoc73">63&nbsp;&nbsp;What can be the difference between applying one hypothesis or another in the context of the last question?</A>
 
138
<LI><A HREF="#htoc74">64&nbsp;&nbsp;My goal is a propositional tautology, how can I prove it?</A>
 
139
<LI><A HREF="#htoc75">65&nbsp;&nbsp;My goal is a first order formula, how can I prove it?</A>
 
140
<LI><A HREF="#htoc76">66&nbsp;&nbsp;My goal is solvable by a sequence of rewrites, how can I prove it?</A>
 
141
<LI><A HREF="#htoc77">67&nbsp;&nbsp;My goal is a disequality solvable by a sequence of rewrites, how can I prove it?</A>
 
142
<LI><A HREF="#htoc78">68&nbsp;&nbsp;My goal is an equality on some ring (e.g. natural numbers), how can I prove it?</A>
 
143
<LI><A HREF="#htoc79">69&nbsp;&nbsp;My goal is an equality on some field (e.g. real numbers), how can I prove it?</A>
 
144
<LI><A HREF="#htoc80">70&nbsp;&nbsp;My goal is an inequality on integers in Presburger's arithmetic (an expression build from +,-,constants and variables), how can I prove it?</A>
 
145
<LI><A HREF="#htoc81">71&nbsp;&nbsp;My goal is an equation solvable using equational hypothesis on some ring (e.g. natural numbers), how can I prove it?</A>
 
146
</UL>
 
147
<LI><A HREF="#htoc82">6.2&nbsp;&nbsp;Tactics usage</A>
 
148
<UL><LI>
 
149
<A HREF="#htoc83">72&nbsp;&nbsp;I want to state a fact that I will use later as an hypothesis, how can I do it?</A>
 
150
<LI><A HREF="#htoc84">73&nbsp;&nbsp;I want to state a fact that I will use later as an hypothesis and prove it later, how can I do it?</A>
 
151
<LI><A HREF="#htoc85">74&nbsp;&nbsp;What is the difference between <TT>Qed</TT> and <TT>Defined</TT>?</A>
 
152
<LI><A HREF="#htoc86">75&nbsp;&nbsp;How can I know what a tactic does?</A>
 
153
<LI><A HREF="#htoc87">76&nbsp;&nbsp;Why <TT>auto</TT> does not work? How can I fix it?</A>
 
154
<LI><A HREF="#htoc88">77&nbsp;&nbsp;What is <TT>eauto</TT>?</A>
 
155
<LI><A HREF="#htoc89">78&nbsp;&nbsp;How can I speed up <TT>auto</TT>?</A>
 
156
<LI><A HREF="#htoc90">79&nbsp;&nbsp;What is the equivalent of <TT>tauto</TT> for classical logic?</A>
 
157
<LI><A HREF="#htoc91">80&nbsp;&nbsp;I want to replace some term with another in the goal, how can I do it?</A>
 
158
<LI><A HREF="#htoc92">81&nbsp;&nbsp;I want to replace some term with another in an hypothesis, how can I do it?</A>
 
159
<LI><A HREF="#htoc93">82&nbsp;&nbsp;I want to replace some symbol with its definition, how can I do it?</A>
 
160
<LI><A HREF="#htoc94">83&nbsp;&nbsp;How can I reduce some term?</A>
 
161
<LI><A HREF="#htoc95">84&nbsp;&nbsp;How can I declare a shortcut for some term?</A>
 
162
<LI><A HREF="#htoc96">85&nbsp;&nbsp;How can I perform case analysis?</A>
 
163
<LI><A HREF="#htoc97">86&nbsp;&nbsp;Why should I name my intros?</A>
 
164
<LI><A HREF="#htoc98">87&nbsp;&nbsp;How can I automatize the naming?</A>
 
165
<LI><A HREF="#htoc99">88&nbsp;&nbsp;I want to automatize the use of some tactic, how can I do it?</A>
 
166
<LI><A HREF="#htoc100">89&nbsp;&nbsp;I want to execute the <TT>p</TT>roof with tactic only if it solves the goal, how can I do it?</A>
 
167
<LI><A HREF="#htoc101">90&nbsp;&nbsp;How can I do the opposite of the <TT>intro</TT> tactic?</A>
 
168
<LI><A HREF="#htoc102">91&nbsp;&nbsp;One of the hypothesis is an equality between a variable and some term, I want to get rid of this variable, how can I do it?</A>
 
169
<LI><A HREF="#htoc103">92&nbsp;&nbsp;What can I do if I get ``<TT>generated subgoal term has metavariables in it </TT>''?</A>
 
170
<LI><A HREF="#htoc104">93&nbsp;&nbsp;How can I instantiate some metavariable?</A>
 
171
<LI><A HREF="#htoc105">94&nbsp;&nbsp;What is the use of the <TT>pattern</TT> tactic?</A>
 
172
<LI><A HREF="#htoc106">95&nbsp;&nbsp;What is the difference between assert, cut and generalize?</A>
 
173
<LI><A HREF="#htoc107">96&nbsp;&nbsp;What can I do if <FONT COLOR=navy>Coq</FONT>can not infer some implicit argument ?</A>
 
174
<LI><A HREF="#htoc108">97&nbsp;&nbsp;How can I explicit some implicit argument ?</A>
 
175
</UL>
 
176
<LI><A HREF="#htoc109">6.3&nbsp;&nbsp;Proof management</A>
 
177
<UL><LI>
 
178
<A HREF="#htoc110">98&nbsp;&nbsp;How can I change the order of the subgoals?</A>
 
179
<LI><A HREF="#htoc111">99&nbsp;&nbsp;How can I change the order of the hypothesis?</A>
 
180
<LI><A HREF="#htoc112">100&nbsp;&nbsp;How can I change the name of an hypothesis?</A>
 
181
<LI><A HREF="#htoc113">101&nbsp;&nbsp;How can I delete some hypothesis?</A>
 
182
<LI><A HREF="#htoc114">102&nbsp;&nbsp;How can use a proof which is not finished?</A>
 
183
<LI><A HREF="#htoc115">103&nbsp;&nbsp;How can I state a conjecture?</A>
 
184
<LI><A HREF="#htoc116">104&nbsp;&nbsp;What is the difference between a lemma, a fact and a theorem?</A>
 
185
<LI><A HREF="#htoc117">105&nbsp;&nbsp;How can I organize my proofs?</A>
 
186
</UL>
 
187
</UL>
 
188
<LI><A HREF="#htoc118">7&nbsp;&nbsp;Inductive and Co-inductive types</A>
 
189
<UL><LI>
 
190
<A HREF="#htoc119">7.1&nbsp;&nbsp;General</A>
 
191
<UL><LI>
 
192
<A HREF="#htoc120">106&nbsp;&nbsp;How can I prove that two constructors are different?</A>
 
193
<LI><A HREF="#htoc121">107&nbsp;&nbsp;During an inductive proof, how to get rid of impossible cases of an inductive definition?</A>
 
194
<LI><A HREF="#htoc122">108&nbsp;&nbsp;How can I prove that 2 terms in an inductive set are equal? Or different?</A>
 
195
<LI><A HREF="#htoc123">109&nbsp;&nbsp;Why is the proof of <TT>0+n=n</TT> on natural numbers
 
196
trivial but the proof of <TT>n+0=n</TT> is not?</A>
 
197
<LI><A HREF="#htoc124">110&nbsp;&nbsp;Why is dependent elimination in Prop not
 
198
available by default?</A>
 
199
</UL>
 
200
<LI><A HREF="#htoc125">7.2&nbsp;&nbsp;Recursion</A>
 
201
<UL><LI>
 
202
<A HREF="#htoc126">111&nbsp;&nbsp;Why can't I define a non terminating program?</A>
 
203
<LI><A HREF="#htoc127">112&nbsp;&nbsp;Why only structurally well-founded loops are allowed?</A>
 
204
<LI><A HREF="#htoc128">113&nbsp;&nbsp;How to define loops based on non structurally smaller
 
205
recursive calls?</A>
 
206
<LI><A HREF="#htoc129">114&nbsp;&nbsp;What is behind the accessibility and well-foundedness proofs?</A>
 
207
<LI><A HREF="#htoc130">115&nbsp;&nbsp;How to perform double induction?</A>
 
208
<LI><A HREF="#htoc131">116&nbsp;&nbsp;How to define a function by double recursion?</A>
 
209
<LI><A HREF="#htoc132">117&nbsp;&nbsp;How to perform nested induction?</A>
 
210
<LI><A HREF="#htoc133">118&nbsp;&nbsp;How to define a function by nested recursion?</A>
 
211
</UL>
 
212
<LI><A HREF="#htoc134">7.3&nbsp;&nbsp;Co-inductive types</A>
 
213
<UL><LI>
 
214
<A HREF="#htoc135">119&nbsp;&nbsp;I have a cofixpoint <I>t</I>:=<I>F</I>(<I>t</I>) and I want to prove <I>t</I>=<I>F</I>(<I>t</I>). How to do it?</A>
 
215
</UL>
 
216
</UL>
 
217
<LI><A HREF="#htoc136">8&nbsp;&nbsp;Syntax and notations</A>
 
218
<UL>
 
219
<UL><LI>
 
220
<A HREF="#htoc137">120&nbsp;&nbsp;I do not want to type ``forall'' because it is too long, what can I do?</A>
 
221
<LI><A HREF="#htoc138">121&nbsp;&nbsp;How can I define a notation for square?</A>
 
222
<LI><A HREF="#htoc139">122&nbsp;&nbsp;Why ``no associativity'' and ``left associativity'' at the same level does not work?</A>
 
223
<LI><A HREF="#htoc140">123&nbsp;&nbsp;How can I know the associativity associated with a level?</A>
 
224
</UL>
 
225
</UL>
 
226
<LI><A HREF="#htoc141">9&nbsp;&nbsp;Modules</A>
 
227
<LI><A HREF="#htoc142">10&nbsp;&nbsp;<FONT COLOR=navy>Ltac</FONT></A>
 
228
<UL>
 
229
<UL><LI>
 
230
<A HREF="#htoc143">124&nbsp;&nbsp;What is <FONT COLOR=navy>Ltac</FONT>?</A>
 
231
<LI><A HREF="#htoc144">125&nbsp;&nbsp;Why do I always get the same error message?</A>
 
232
<LI><A HREF="#htoc145">126&nbsp;&nbsp;Is there any printing command in <FONT COLOR=navy>Ltac</FONT>?</A>
 
233
<LI><A HREF="#htoc146">127&nbsp;&nbsp;What is the syntax for let in <FONT COLOR=navy>Ltac</FONT>?</A>
 
234
<LI><A HREF="#htoc147">128&nbsp;&nbsp;What is the syntax for pattern matching in <FONT COLOR=navy>Ltac</FONT>?</A>
 
235
<LI><A HREF="#htoc148">129&nbsp;&nbsp;What is the semantics for match goal?</A>
 
236
<LI><A HREF="#htoc149">130&nbsp;&nbsp;How can I generate a new name?</A>
 
237
<LI><A HREF="#htoc150">131&nbsp;&nbsp;How can I define static and dynamic code?</A>
 
238
</UL>
 
239
</UL>
 
240
<LI><A HREF="#htoc151">11&nbsp;&nbsp;Tactics written in Ocaml</A>
 
241
<UL>
 
242
<UL><LI>
 
243
<A HREF="#htoc152">132&nbsp;&nbsp;Can you show me an example of a tactic written in OCaml?</A>
 
244
</UL>
 
245
</UL>
 
246
<LI><A HREF="#htoc153">12&nbsp;&nbsp;Case studies</A>
 
247
<UL>
 
248
<UL><LI>
 
249
<A HREF="#htoc154">133&nbsp;&nbsp;How can I define vectors or lists of size n?</A>
 
250
<LI><A HREF="#htoc155">134&nbsp;&nbsp;How to prove that 2 sets are different?</A>
 
251
<LI><A HREF="#htoc156">135&nbsp;&nbsp;Is there an axiom-free proof of Streicher's axiom <I>K</I> for
 
252
the equality on <TT>nat</TT>?</A>
 
253
<LI><A HREF="#htoc157">136&nbsp;&nbsp;How to prove that two proofs of <TT>n&lt;=m</TT> on <TT>nat</TT> are equal?</A>
 
254
<LI><A HREF="#htoc158">137&nbsp;&nbsp;How to exploit equalities on sets</A>
 
255
<LI><A HREF="#htoc159">138&nbsp;&nbsp;I have a problem of dependent elimination on
 
256
proofs, how to solve it?</A>
 
257
<LI><A HREF="#htoc160">139&nbsp;&nbsp;And what if I want to prove the following?</A>
 
258
</UL>
 
259
</UL>
 
260
<LI><A HREF="#htoc161">13&nbsp;&nbsp;Publishing tools</A>
 
261
<UL>
 
262
<UL><LI>
 
263
<A HREF="#htoc162">140&nbsp;&nbsp;How can I generate some latex from my development?</A>
 
264
<LI><A HREF="#htoc163">141&nbsp;&nbsp;How can I generate some HTML from my development?</A>
 
265
<LI><A HREF="#htoc164">142&nbsp;&nbsp;How can I generate some dependency graph from my development?</A>
 
266
<LI><A HREF="#htoc165">143&nbsp;&nbsp;How can I cite some <FONT COLOR=navy>Coq</FONT> in my latex document?</A>
 
267
<LI><A HREF="#htoc166">144&nbsp;&nbsp;How can I cite the <FONT COLOR=navy>Coq</FONT> reference manual?</A>
 
268
<LI><A HREF="#htoc167">145&nbsp;&nbsp;Where can I publish my developments in <FONT COLOR=navy>Coq</FONT>?</A>
 
269
<LI><A HREF="#htoc168">146&nbsp;&nbsp;How can I read my proof in natural language?</A>
 
270
</UL>
 
271
</UL>
 
272
<LI><A HREF="#htoc169">14&nbsp;&nbsp;<FONT COLOR=navy>CoqIde</FONT></A>
 
273
<UL>
 
274
<UL><LI>
 
275
<A HREF="#htoc170">147&nbsp;&nbsp;What is <FONT COLOR=navy>CoqIde</FONT>?</A>
 
276
<LI><A HREF="#htoc171">148&nbsp;&nbsp;How to enable Emacs keybindings?</A>
 
277
<LI><A HREF="#htoc172">149&nbsp;&nbsp;How to enable antialiased fonts?</A>
 
278
<LI><A HREF="#htoc173">150&nbsp;&nbsp;How to use those Forall and Exists pretty symbols?</A>
 
279
<LI><A HREF="#htoc174">151&nbsp;&nbsp;How to define an input method for non ASCII symbols?</A>
 
280
<LI><A HREF="#htoc175">152&nbsp;&nbsp;How to build a custom <FONT COLOR=navy>CoqIde</FONT> with user ml code?</A>
 
281
<LI><A HREF="#htoc176">153&nbsp;&nbsp;How to customize the shortcuts for menus?</A>
 
282
<LI><A HREF="#htoc177">154&nbsp;&nbsp;What encoding should I use? What is this \x{iiii} in my file?</A>
 
283
</UL>
 
284
</UL>
 
285
<LI><A HREF="#htoc178">15&nbsp;&nbsp;Extraction</A>
 
286
<UL>
 
287
<UL><LI>
 
288
<A HREF="#htoc179">155&nbsp;&nbsp;What is program extraction?</A>
 
289
<LI><A HREF="#htoc180">156&nbsp;&nbsp;Which language can I extract to?</A>
 
290
<LI><A HREF="#htoc181">157&nbsp;&nbsp;How can I extract an incomplete proof?</A>
 
291
</UL>
 
292
</UL>
 
293
<LI><A HREF="#htoc182">16&nbsp;&nbsp;Glossary</A>
 
294
<UL>
 
295
<UL><LI>
 
296
<A HREF="#htoc183">158&nbsp;&nbsp;Can you explain me what an evaluable constant is?</A>
 
297
<LI><A HREF="#htoc184">159&nbsp;&nbsp;What is a goal?</A>
 
298
<LI><A HREF="#htoc185">160&nbsp;&nbsp;What is a meta variable?</A>
 
299
<LI><A HREF="#htoc186">161&nbsp;&nbsp;What is Gallina?</A>
 
300
<LI><A HREF="#htoc187">162&nbsp;&nbsp;What is The Vernacular?</A>
 
301
<LI><A HREF="#htoc188">163&nbsp;&nbsp;What is a dependent type?</A>
 
302
<LI><A HREF="#htoc189">164&nbsp;&nbsp;What is a proof by reflection?</A>
 
303
<LI><A HREF="#htoc190">165&nbsp;&nbsp;What is intuitionistic logic?</A>
 
304
<LI><A HREF="#htoc191">166&nbsp;&nbsp;What is proof-irrelevance?</A>
 
305
<LI><A HREF="#htoc192">167&nbsp;&nbsp;What is the difference between opaque and transparent?</A>
 
306
</UL>
 
307
</UL>
 
308
<LI><A HREF="#htoc193">17&nbsp;&nbsp;Troubleshooting</A>
 
309
<UL>
 
310
<UL><LI>
 
311
<A HREF="#htoc194">168&nbsp;&nbsp;What can I do when <TT>Qed.</TT> is slow?</A>
 
312
<LI><A HREF="#htoc195">169&nbsp;&nbsp;Why <TT>Reset Initial.</TT> does not work when using <TT>coqc</TT>?</A>
 
313
<LI><A HREF="#htoc196">170&nbsp;&nbsp;What can I do if I get ``No more subgoals but non-instantiated existential variables''?</A>
 
314
<LI><A HREF="#htoc197">171&nbsp;&nbsp;What can I do if I get ``Cannot solve a second-order unification problem''?</A>
 
315
<LI><A HREF="#htoc198">172&nbsp;&nbsp;Why does <FONT COLOR=navy>Coq</FONT> tell me that <TT>{x:A|(P x)}</TT> is not convertible with <TT>(sig A P)</TT>?</A>
 
316
<LI><A HREF="#htoc199">173&nbsp;&nbsp;I copy-paste a term and <FONT COLOR=navy>Coq</FONT> says it is not convertible
 
317
 to the original term. Sometimes it even says the copied term is not
 
318
well-typed.</A>
 
319
</UL>
 
320
</UL>
 
321
<LI><A HREF="#htoc200">18&nbsp;&nbsp;Conclusion and Farewell.</A>
 
322
<UL>
 
323
<UL><LI>
 
324
<A HREF="#htoc201">174&nbsp;&nbsp;What if my question isn't answered here?</A>
 
325
</UL>
 
326
</UL>
 
327
</UL>
 
328
 
 
329
<!--TOC section Introduction-->
 
330
 
 
331
<H2><A NAME="htoc1">1</A>&nbsp;&nbsp;Introduction</H2><!--SEC END -->
 
332
 
 
333
This FAQ is the sum of the questions that came to mind as we developed
 
334
proofs in <FONT COLOR=navy>Coq</FONT>. Since we are singularly short-minded, we wrote the
 
335
answers we found on bits of papers to have them at hand whenever the
 
336
situation occurs again. This is pretty much the result of that: a
 
337
collection of tips one can refer to when proofs become intricate. Yes,
 
338
this means we won't take the blame for the shortcomings of this
 
339
FAQ. But if you want to contribute and send in your own question and
 
340
answers, feel free to write to us...<BR>
 
341
<BR>
 
342
<!--TOC section Presentation-->
 
343
 
 
344
<H2><A NAME="htoc2">2</A>&nbsp;&nbsp;Presentation</H2><!--SEC END -->
 
345
 
 
346
<!--TOC subsubsection What is <FONT COLOR=navy>Coq</FONT>?-->
 
347
 
 
348
<H4><A NAME="htoc3">1</A>&nbsp;&nbsp;What is <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
349
<A NAME="whatiscoq"></A> 
 
350
The <FONT COLOR=navy>Coq</FONT> tool is a formal proof management system: a proof done with <FONT COLOR=navy>Coq</FONT> is mechanically checked by the machine. 
 
351
In particular, <FONT COLOR=navy>Coq</FONT> allows:
 
352
<UL><LI>
 
353
 the definition of functions or predicates,
 
354
 <LI>to state mathematical theorems and software specifications,
 
355
 <LI>to develop interactively formal proofs of these theorems,
 
356
 <LI>to check these proofs by a small certification "kernel".
 
357
</UL>
 
358
<FONT COLOR=navy>Coq</FONT> is based on a logical framework called "Calculus of Inductive Constructions" extended by a modular development system for theories.<BR>
 
359
<BR>
 
360
<!--TOC subsubsection Did you really need to name it like that?-->
 
361
 
 
362
<H4><A NAME="htoc4">2</A>&nbsp;&nbsp;Did you really need to name it like that?</H4><!--SEC END -->
 
363
 
 
364
Some French computer scientists have a tradition of naming their
 
365
software as animal species: Caml, Elan, Foc or Phox are examples
 
366
of this tacit convention. In French, ``coq'' means rooster, and it
 
367
sounds like the initials of the Calculus of Constructions CoC on which
 
368
it is based.<BR>
 
369
<BR>
 
370
<!--TOC subsubsection Is <FONT COLOR=navy>Coq</FONT> a theorem prover?-->
 
371
 
 
372
<H4><A NAME="htoc5">3</A>&nbsp;&nbsp;Is <FONT COLOR=navy>Coq</FONT> a theorem prover?</H4><!--SEC END -->
 
373
 
 
374
<FONT COLOR=navy>Coq</FONT> comes with a few decision procedures (on propositional
 
375
calculus, Presburger's arithmetic, ring and field simplification,
 
376
resolution, ...) but the main style for proving theorems is
 
377
interactively by using LCF-style tactics.<BR>
 
378
<BR>
 
379
<!--TOC subsubsection What are the other theorem provers?-->
 
380
 
 
381
<H4><A NAME="htoc6">4</A>&nbsp;&nbsp;What are the other theorem provers?</H4><!--SEC END -->
 
382
 
 
383
Many other theorem provers are available for use nowadays. 
 
384
Isabelle, HOL, HOL Light, Lego, Nuprl, PVS are examples of provers that are fairly similar
 
385
to <FONT COLOR=navy>Coq</FONT> by the way they interact with the user. Other relatives of
 
386
<FONT COLOR=navy>Coq</FONT> are ACL2, Alfa, Elf, Kiv, Mizar, NqThm, 
 
387
Omega...
 
388
<BR>
 
389
<BR>
 
390
<!--TOC subsubsection Who do I have to trust when I see a proof checked by Coq?-->
 
391
 
 
392
<H4><A NAME="htoc7">5</A>&nbsp;&nbsp;Who do I have to trust when I see a proof checked by Coq?</H4><!--SEC END -->
 
393
 
 
394
You have to trust:
 
395
<DL COMPACT=compact><DT>
 
396
<B>The theory behind Coq</B><DD> The theory of <FONT COLOR=navy>Coq</FONT> version 8.0 is
 
397
generally admitted to be consistent wrt Zermelo-Fraenkel set theory +
 
398
inaccessibles cardinals. Proofs of consistency of subsystems of the
 
399
theory of Coq can be found in the literature.
 
400
<DT><B>The Coq kernel implementation</B><DD> You have to trust that the
 
401
implementation of the <FONT COLOR=navy>Coq</FONT> kernel mirrors the theory behind <FONT COLOR=navy>Coq</FONT>. The
 
402
kernel is intentionally small to limit the risk of conceptual or
 
403
accidental implementation bugs.
 
404
<DT><B>The Objective Caml compiler</B><DD> The <FONT COLOR=navy>Coq</FONT> kernel is written using the
 
405
Objective Caml language but it uses only the most standard features
 
406
(no object, no label ...), so that it is highly unprobable that an
 
407
Objective Caml bug breaks the consistency of <FONT COLOR=navy>Coq</FONT> without breaking all
 
408
other kinds of features of <FONT COLOR=navy>Coq</FONT> or of other software compiled with
 
409
Objective Caml.
 
410
<DT><B>Your hardware</B><DD> In theory, if your hardware does not work
 
411
properly, it can accidentally be the case that False becomes
 
412
provable. But it is more likely the case that the whole <FONT COLOR=navy>Coq</FONT> system
 
413
will be unusable. You can check your proof using different computers
 
414
if you feel the need to.
 
415
<DT><B>Your axioms</B><DD> Your axioms must be consistent with the theory
 
416
behind <FONT COLOR=navy>Coq</FONT>.
 
417
</DL>
 
418
<!--TOC subsubsection Where can I find information about the theory behind <FONT COLOR=navy>Coq</FONT>?-->
 
419
 
 
420
<H4><A NAME="htoc8">6</A>&nbsp;&nbsp;Where can I find information about the theory behind <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
421
 
 
422
<DL COMPACT=compact><DT>
 
423
<B>The Calculus of Inductive Constructions</B><DD> The
 
424
<A HREF="http://coq.inria.fr/doc/Reference-Manual006.html">corresponding</A>
 
425
chapter and the chapter on
 
426
<A HREF="http://coq.inria.fr/doc/Reference-Manual007.html">modules</A> in
 
427
the <FONT COLOR=navy>Coq</FONT> Reference Manual.
 
428
<DT><B>Type theory</B><DD> A book&nbsp;[<A HREF="#ProofsTypes"><CITE>10</CITE></A>] or some lecture
 
429
notes&nbsp;[<A HREF="#Types:Dowek"><CITE>7</CITE></A>].
 
430
<DT><B>Inductive types</B><DD>
 
431
Christine Paulin-Mohring's habilitation thesis&nbsp;[<A HREF="#Pau96b"><CITE>17</CITE></A>].
 
432
<DT><B>Co-Inductive types</B><DD>
 
433
Eduardo Gim�nez' thesis&nbsp;[<A HREF="#EGThese"><CITE>8</CITE></A>].
 
434
<DT><B>Miscellaneous</B><DD> A
 
435
<A HREF="http://coq.inria.fr/doc/biblio.html">bibliography</A> about Coq
 
436
</DL>
 
437
<!--TOC subsubsection How can I use <FONT COLOR=navy>Coq</FONT> to prove programs?-->
 
438
 
 
439
<H4><A NAME="htoc9">7</A>&nbsp;&nbsp;How can I use <FONT COLOR=navy>Coq</FONT> to prove programs?</H4><!--SEC END -->
 
440
 
 
441
You can either extract a program from a proof by using the extraction
 
442
mechanism or use dedicated tools, such as
 
443
<A HREF="http://why.lri.fr"><FONT COLOR=navy>Why</FONT></A>,
 
444
<A HREF="http://krakatoa.lri.fr"><FONT COLOR=navy>Krakatoa</FONT></A>,
 
445
<A HREF="http://why.lri.fr/caduceus/index.en.html"><FONT COLOR=navy>Caduceus</FONT></A>, to prove
 
446
annotated programs written in other languages.<BR>
 
447
<BR>
 
448
<!--TOC subsubsection How many <FONT COLOR=navy>Coq</FONT> users are there?-->
 
449
 
 
450
<H4><A NAME="htoc10">8</A>&nbsp;&nbsp;How many <FONT COLOR=navy>Coq</FONT> users are there?</H4><!--SEC END -->
 
451
 
 
452
An estimation is about 100 regular users.<BR>
 
453
<BR>
 
454
<!--TOC subsubsection How old is <FONT COLOR=navy>Coq</FONT>?-->
 
455
 
 
456
<H4><A NAME="htoc11">9</A>&nbsp;&nbsp;How old is <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
457
 
 
458
The first implementation is from 1985 (it was named <FONT COLOR=purple>CoC</FONT> which is
 
459
the acronym of the name of the logic it implemented: the Calculus of
 
460
Constructions). The first official release of <FONT COLOR=navy>Coq</FONT> (version 4.10)
 
461
was distributed in 1989.<BR>
 
462
<BR>
 
463
<!--TOC subsubsection What are the <FONT COLOR=navy>Coq</FONT>-related tools?-->
 
464
 
 
465
<H4><A NAME="htoc12">10</A>&nbsp;&nbsp;What are the <FONT COLOR=navy>Coq</FONT>-related tools?</H4><!--SEC END -->
 
466
 
 
467
<DL COMPACT=compact><DT>
 
468
<B>Coqide</B><DD> A GTK based GUI for <FONT COLOR=navy>Coq</FONT>.
 
469
<DT><B>Pcoq</B><DD> A GUI for <FONT COLOR=navy>Coq</FONT> with proof by pointing and pretty printing.
 
470
<DT><B>Helm/Mowgli</B><DD> A rendering, searching and publishing tool.
 
471
<DT><B>Why</B><DD> A back-end generator of verification conditions.
 
472
<DT><B>Krakatoa</B><DD> A Java code certification tool that uses both <FONT COLOR=navy>Coq</FONT> and <FONT COLOR=navy>Why</FONT> to verify the soundness of implementations with regards to the specifications.
 
473
<DT><B>Caduceus</B><DD> A C code certification tool that uses both <FONT COLOR=navy>Coq</FONT> and <FONT COLOR=navy>Why</FONT>.
 
474
<DT><B>coqwc</B><DD> A tool similar to <TT>wc</TT> to count lines in <FONT COLOR=navy>Coq</FONT> files.
 
475
<DT><B>coq-tex</B><DD> A tool to insert <FONT COLOR=navy>Coq</FONT> examples within .tex files. 
 
476
<DT><B>coqdoc</B><DD> A documentation tool for <FONT COLOR=navy>Coq</FONT>.
 
477
<DT><B>Proof General</B><DD> A emacs mode for <FONT COLOR=navy>Coq</FONT> and many other proof assistants.
 
478
<DT><B>Foc</B><DD> The <A HREF="http://www-spi.lip6.fr/foc/index-en.html">Foc</A> project aims at building an environment to develop certified computer algebra libraries. 
 
479
</DL>
 
480
<!--TOC subsubsection What are the high-level tactics of <FONT COLOR=navy>Coq</FONT>-->
 
481
 
 
482
<H4><A NAME="htoc13">11</A>&nbsp;&nbsp;What are the high-level tactics of <FONT COLOR=navy>Coq</FONT></H4><!--SEC END -->
 
483
 
 
484
<UL><LI>
 
485
Decision of quantifier-free Presburger's Arithmetic
 
486
<LI>Simplification of expressions on rings and fields
 
487
<LI>Decision of closed systems of equations
 
488
<LI>Semi-decision of first-order logic
 
489
<LI>Prolog-style proof search, possibly involving equalities
 
490
</UL>
 
491
<!--TOC subsubsection What are the main libraries available for <FONT COLOR=navy>Coq</FONT>-->
 
492
 
 
493
<H4><A NAME="htoc14">12</A>&nbsp;&nbsp;What are the main libraries available for <FONT COLOR=navy>Coq</FONT></H4><!--SEC END -->
 
494
 
 
495
<UL><LI>
 
496
Basic Peano's arithmetic, binary integer numbers, rational numbers,
 
497
<LI>Real analysis,
 
498
<LI>Libraries for lists, boolean, maps, floating-point numbers,
 
499
<LI>Libraries for relations, sets and constructive algebra,
 
500
<LI>Geometry
 
501
</UL>
 
502
<!--TOC subsubsection What are the academic applications for <FONT COLOR=navy>Coq</FONT>?-->
 
503
 
 
504
<H4><A NAME="htoc15">13</A>&nbsp;&nbsp;What are the academic applications for <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
505
 
 
506
<FONT COLOR=navy>Coq</FONT> is used for formalizing mathematical theories, for teaching,
 
507
and for proving properties of algorithms or programs libraries.<BR>
 
508
<BR>
 
509
The largest mathematical formalization has been done at the University
 
510
of Nijmegen (see the
 
511
<A HREF="http://vacuumcleaner.cs.kun.nl/c-corn">Constructive Coq
 
512
Repository at Nijmegen</A>).<BR>
 
513
<BR>
 
514
<!--TOC subsubsection What are the industrial applications for <FONT COLOR=navy>Coq</FONT>?-->
 
515
 
 
516
<H4><A NAME="htoc16">14</A>&nbsp;&nbsp;What are the industrial applications for <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
517
 
 
518
<FONT COLOR=navy>Coq</FONT> is used e.g. to prove properties of the JavaCard system
 
519
(especially by the companies Schlumberger and Trusted Logic). It has
 
520
also been used to formalize the semantics of the Lucid-Synchrone
 
521
data-flow synchronous calculus used by Esterel-Technologies.<BR>
 
522
<BR>
 
523
<!--TOC section Documentation-->
 
524
 
 
525
<H2><A NAME="htoc17">3</A>&nbsp;&nbsp;Documentation</H2><!--SEC END -->
 
526
 
 
527
<!--TOC subsubsection Where can I find documentation about <FONT COLOR=navy>Coq</FONT>?-->
 
528
 
 
529
<H4><A NAME="htoc18">15</A>&nbsp;&nbsp;Where can I find documentation about <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
530
 
 
531
All the documentation about <FONT COLOR=navy>Coq</FONT>, from the reference manual&nbsp;[<A HREF="#Coq:manual"><CITE>15</CITE></A>] to
 
532
friendly tutorials&nbsp;[<A HREF="#Coq:Tutorial"><CITE>14</CITE></A>] and documentation of the standard library, is available 
 
533
<A HREF="http://coq.inria.fr/doc-eng.html">online</A>.
 
534
All these documents are viewable either in browsable HTML, or as
 
535
downloadable postscripts.<BR>
 
536
<BR>
 
537
<!--TOC subsubsection Where can I find this FAQ on the web?-->
 
538
 
 
539
<H4><A NAME="htoc19">16</A>&nbsp;&nbsp;Where can I find this FAQ on the web?</H4><!--SEC END -->
 
540
 
 
541
This FAQ is available online at <A HREF="http://coq.inria.fr/doc/faq.html"><TT>http://coq.inria.fr/doc/faq.html</TT></A>.<BR>
 
542
<BR>
 
543
<!--TOC subsubsection How can I submit suggestions / improvements / additions for this FAQ?-->
 
544
 
 
545
<H4><A NAME="htoc20">17</A>&nbsp;&nbsp;How can I submit suggestions / improvements / additions for this FAQ?</H4><!--SEC END -->
 
546
 
 
547
This FAQ is unfinished (in the sense that there are some obvious
 
548
sections that are missing). Please send contributions to <TT>Florent.Kirchner at lix.polytechnique.fr</TT> and <TT>Julien.Narboux at inria.fr</TT>.<BR>
 
549
<BR>
 
550
<!--TOC subsubsection Is there any mailing list about <FONT COLOR=navy>Coq</FONT>?-->
 
551
 
 
552
<H4><A NAME="htoc21">18</A>&nbsp;&nbsp;Is there any mailing list about <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
553
 
 
554
The main <FONT COLOR=navy>Coq</FONT> mailing list is <TT>coq-club@coq.inria.fr</TT>, which
 
555
broadcasts questions and suggestions about the implementation, the
 
556
logical formalism or proof developments. See
 
557
<A HREF="http://coq.inria.fr/mailman/listinfo/coq-club"><TT>http://coq.inria.fr/mailman/listinfo/coq-club</TT></A> for
 
558
subscription. For bugs reports see question <A HREF="#coqbug">23</A>.<BR>
 
559
<BR>
 
560
<!--TOC subsubsection Where can I find an archive of the list?-->
 
561
 
 
562
<H4><A NAME="htoc22">19</A>&nbsp;&nbsp;Where can I find an archive of the list?</H4><!--SEC END -->
 
563
 
 
564
The archives of the <FONT COLOR=navy>Coq</FONT> mailing list are available at
 
565
<A HREF="http://coq.inria.fr/pipermail/coq-club"><TT>http://coq.inria.fr/pipermail/coq-club</TT></A>.<BR>
 
566
<BR>
 
567
<!--TOC subsubsection How can I be kept informed of new releases of <FONT COLOR=navy>Coq</FONT>?-->
 
568
 
 
569
<H4><A NAME="htoc23">20</A>&nbsp;&nbsp;How can I be kept informed of new releases of <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
570
 
 
571
New versions of <FONT COLOR=navy>Coq</FONT> are announced on the coq-club mailing list. If you only want to receive information about new releases, you can subscribe to <FONT COLOR=navy>Coq</FONT> on <A HREF="http://freshmeat.net/projects/coq/"><TT>http://freshmeat.net/projects/coq/</TT></A>.<BR>
 
572
<BR>
 
573
<!--TOC subsubsection Is there any book about <FONT COLOR=navy>Coq</FONT>?-->
 
574
 
 
575
<H4><A NAME="htoc24">21</A>&nbsp;&nbsp;Is there any book about <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
576
 
 
577
The first book on <FONT COLOR=navy>Coq</FONT>, Yves Bertot and Pierre Cast�ran's Coq'Art has been published by Springer-Verlag in 2004:
 
578
<BLOCKQUOTE>
 
579
``This book provides a pragmatic introduction to the development of
 
580
proofs and certified programs using <FONT COLOR=navy>Coq</FONT>. With its large collection of
 
581
examples and exercises it is an invaluable tool for researchers,
 
582
students, and engineers interested in formal methods and the
 
583
development of zero-default software.''
 
584
</BLOCKQUOTE>
 
585
<!--TOC subsubsection Where can I find some <FONT COLOR=navy>Coq</FONT> examples?-->
 
586
 
 
587
<H4><A NAME="htoc25">22</A>&nbsp;&nbsp;Where can I find some <FONT COLOR=navy>Coq</FONT> examples?</H4><!--SEC END -->
 
588
 
 
589
There are examples in the manual&nbsp;[<A HREF="#Coq:manual"><CITE>15</CITE></A>] and in the
 
590
Coq'Art&nbsp;[<A HREF="#Coq:coqart"><CITE>1</CITE></A>] exercises <A HREF="http://www.labri.fr/Perso/ casteran/CoqArt/index.html"><TT>http://www.labri.fr/Perso/~casteran/CoqArt/index.html</TT></A>.
 
591
You can also find large developments using
 
592
<FONT COLOR=navy>Coq</FONT> in the <FONT COLOR=navy>Coq</FONT> user contributions:
 
593
<A HREF="http://coq.inria.fr/contrib-eng.html"><TT>http://coq.inria.fr/contrib-eng.html</TT></A>.<BR>
 
594
<BR>
 
595
<!--TOC subsubsection How can I report a bug?-->
 
596
 
 
597
<H4><A NAME="htoc26">23</A>&nbsp;&nbsp;How can I report a bug?</H4><!--SEC END -->
 
598
<A NAME="coqbug"></A>
 
599
You can use the web interface at <A HREF="http://coq.inria.fr/bin/coq-bugs"><TT>http://coq.inria.fr/bin/coq-bugs</TT></A>.<BR>
 
600
<BR>
 
601
<!--TOC section Installation-->
 
602
 
 
603
<H2><A NAME="htoc27">4</A>&nbsp;&nbsp;Installation</H2><!--SEC END -->
 
604
 
 
605
<!--TOC subsubsection What is the license of <FONT COLOR=navy>Coq</FONT>?-->
 
606
 
 
607
<H4><A NAME="htoc28">24</A>&nbsp;&nbsp;What is the license of <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
608
 
 
609
The main files are distributed under the GNU Lesser General License
 
610
(LGPL). A few contributions are GPL.<BR>
 
611
<BR>
 
612
<!--TOC subsubsection Where can I find the sources of <FONT COLOR=navy>Coq</FONT>?-->
 
613
 
 
614
<H4><A NAME="htoc29">25</A>&nbsp;&nbsp;Where can I find the sources of <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
615
 
 
616
The sources of <FONT COLOR=navy>Coq</FONT> can be found online in the tar.gz'ed packages
 
617
(<A HREF="http://coq.inria.fr/distrib-eng.html"><TT>http://coq.inria.fr/distrib-eng.html</TT></A>). Development sources can
 
618
be accessed via anonymous CVS: <A HREF="http://coqcvs.inria.fr/"><TT>http://coqcvs.inria.fr/</TT></A><BR>
 
619
<BR>
 
620
<!--TOC subsubsection On which platform is <FONT COLOR=navy>Coq</FONT> available?-->
 
621
 
 
622
<H4><A NAME="htoc30">26</A>&nbsp;&nbsp;On which platform is <FONT COLOR=navy>Coq</FONT> available?</H4><!--SEC END -->
 
623
 
 
624
Compiled binaries are available for Linux, MacOS X, Solaris, and
 
625
Windows. The sources can be easily compiled on all platforms supporting Objective Caml.<BR>
 
626
<BR>
 
627
<!--TOC section The logic of <FONT COLOR=navy>Coq</FONT>-->
 
628
 
 
629
<H2><A NAME="htoc31">5</A>&nbsp;&nbsp;The logic of <FONT COLOR=navy>Coq</FONT></H2><!--SEC END -->
 
630
 
 
631
<!--TOC subsection General-->
 
632
 
 
633
<H3><A NAME="htoc32">5.1</A>&nbsp;&nbsp;General</H3><!--SEC END -->
 
634
 
 
635
<!--TOC subsubsection What is the logic of <FONT COLOR=navy>Coq</FONT>?-->
 
636
 
 
637
<H4><A NAME="htoc33">27</A>&nbsp;&nbsp;What is the logic of <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
638
 
 
639
<FONT COLOR=navy>Coq</FONT> is based on an axiom-free type theory called
 
640
the Calculus of Inductive Constructions (see Coquand [<A HREF="#CoHu86"><CITE>5</CITE></A>]
 
641
and Coquand--Paulin-Mohring [<A HREF="#CoPa89"><CITE>6</CITE></A>]). It includes higher-order
 
642
functions and predicates, inductive and co-inductive datatypes and
 
643
predicates, and a stratified hierarchy of sets.<BR>
 
644
<BR>
 
645
<!--TOC subsubsection Is <FONT COLOR=navy>Coq</FONT>'s logic intuitionistic or classical?-->
 
646
 
 
647
<H4><A NAME="htoc34">28</A>&nbsp;&nbsp;Is <FONT COLOR=navy>Coq</FONT>'s logic intuitionistic or classical?</H4><!--SEC END -->
 
648
 
 
649
<FONT COLOR=navy>Coq</FONT> theory is basically intuitionistic
 
650
(i.e. excluded-middle <I>A</I>\/� <I>A</I> is not granted by default) with
 
651
the possibility to reason classically on demand by requiring an
 
652
optional axiom stating <I>A</I>\/� <I>A</I>.<BR>
 
653
<BR>
 
654
<!--TOC subsubsection Can I define non-terminating programs in <FONT COLOR=navy>Coq</FONT>?-->
 
655
 
 
656
<H4><A NAME="htoc35">29</A>&nbsp;&nbsp;Can I define non-terminating programs in <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
657
 
 
658
No, all programs in <FONT COLOR=navy>Coq</FONT> are terminating. Especially, loops
 
659
must come with an evidence of their termination.<BR>
 
660
<BR>
 
661
<!--TOC subsubsection How is equational reasoning working in <FONT COLOR=navy>Coq</FONT>?-->
 
662
 
 
663
<H4><A NAME="htoc36">30</A>&nbsp;&nbsp;How is equational reasoning working in <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
664
 
 
665
<FONT COLOR=navy>Coq</FONT> comes with an internal notion of computation called
 
666
<EM>conversion</EM> (e.g. (<I>x</I>+1)+<I>y</I> is internally equivalent to
 
667
(<I>x</I>+<I>y</I>)+1; similarly applying argument <I>a</I> to a function mapping <I>x</I>
 
668
to some expression <I>t</I> converts to the expression <I>t</I> where <I>x</I> is
 
669
replaced by <I>a</I>). This notion of conversion (which is decidable
 
670
because <FONT COLOR=navy>Coq</FONT> programs are terminating) covers a certain part of
 
671
equational reasoning but is limited to sequential evaluation of
 
672
expressions of (not necessarily closed) programs. Besides conversion,
 
673
equations have to be treated by hand or using specialised tactics.<BR>
 
674
<BR>
 
675
<!--TOC subsection Axioms-->
 
676
 
 
677
<H3><A NAME="htoc37">5.2</A>&nbsp;&nbsp;Axioms</H3><!--SEC END -->
 
678
 
 
679
<!--TOC subsubsection What axioms can be safely added to <FONT COLOR=navy>Coq</FONT>?-->
 
680
 
 
681
<H4><A NAME="htoc38">31</A>&nbsp;&nbsp;What axioms can be safely added to <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
682
 
 
683
There are a few typical useful axioms that are independent from the
 
684
Calculus of Inductive Constructions and that can be safely added to
 
685
<FONT COLOR=navy>Coq</FONT>. These axioms are stated in the directory <TT>Logic</TT> of the
 
686
standard library of <FONT COLOR=navy>Coq</FONT>. The most interesting ones are
 
687
<UL><LI>
 
688
Excluded-middle: for all <I>A</I>:<I>Prop</I>, <I>A</I> \/ � <I>A</I>
 
689
<LI>Proof-irrelevance: for all <I>A</I>:<I>Prop</I>, for all <I>p</I><SUB><FONT SIZE=2>1</FONT></SUB> <I>p</I><SUB><FONT SIZE=2>2</FONT></SUB>:<I>A</I>, <I>p</I><SUB><FONT SIZE=2>1</FONT></SUB>=<I>p</I><SUB><FONT SIZE=2>2</FONT></SUB>
 
690
<LI>Unicity of equality proofs (or equivalently Streicher's axiom <I>K</I>)
 
691
<LI>The principle of description: for all <I>x</I>, there exists! <I>y</I>, <I>R</I>(<I>x</I>,<I>y</I>) -&gt; there exists <I>f</I>, for all <I>x</I>, <I>R</I>(<I>x</I>,<I>f</I>(<I>x</I>))
 
692
<LI>The functional axiom of choice: for all <I>x</I>, there exists <I>y</I>, <I>R</I>(<I>x</I>,<I>y</I>) -&gt; there exists <I>f</I>, for all <I>x</I>, <I>R</I>(<I>x</I>,<I>f</I>(<I>x</I>))
 
693
<LI>Extensionality of predicates: for all <I>P</I> <I>Q</I>:<I>A</I>-&gt; <I>Prop</I>, (for all <I>x</I>, <I>P</I>(<I>x</I>) &lt;-&gt; <I>Q</I>(<I>x</I>)) -&gt; <I>P</I>=<I>Q</I>
 
694
<LI>Extensionality of functions: for all <I>f</I> <I>g</I>:<I>A</I>-&gt; <I>B</I>, (for all <I>x</I>, <I>f</I>(<I>x</I>)=<I>g</I>(<I>x</I>)) -&gt; <I>f</I>=<I>g</I>
 
695
</UL>
 
696
Here is a summary of the relative strength of these axioms, most
 
697
proofs can be found in directory <TT>Logic</TT> of the standard library.<BR>
 
698
<BR>
 
699
<IMG SRC="main.v001.gif"><BR>
 
700
<BR>
 
701
<!--TOC subsubsection What standard axioms are inconsistent with <FONT COLOR=navy>Coq</FONT>?-->
 
702
 
 
703
<H4><A NAME="htoc39">32</A>&nbsp;&nbsp;What standard axioms are inconsistent with <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
704
 
 
705
The axiom of description together with classical logic
 
706
(e.g. excluded-middle) are inconsistent in the variant of the Calculus
 
707
of Inductive Constructions where <TT>Set</TT> is impredicative.<BR>
 
708
<BR>
 
709
As a consequence, the functional form of the axiom of choice and
 
710
excluded-middle, or any form of the axiom of choice together with
 
711
predicate extensionality are inconsistent in the <TT>Set</TT>-impredicative
 
712
version of the Calculus of Inductive Constructions.<BR>
 
713
<BR>
 
714
The main purpose of the <TT>Set</TT>-predicative restriction of the Calculus
 
715
of Inductive Constructions is precisely to accommodate these axioms
 
716
which are quite standard in mathematical usage.<BR>
 
717
<BR>
 
718
The <TT><I>Set</I></TT>-predicative system is commonly considered consistent by
 
719
interpreting it in a standard set-theoretic boolean model, even with
 
720
classical logic, axiom of choice and predicate extensionality added.<BR>
 
721
<BR>
 
722
<!--TOC subsubsection What is Streicher's axiom <I>K</I>-->
 
723
 
 
724
<H4><A NAME="htoc40">33</A>&nbsp;&nbsp;What is Streicher's axiom <I>K</I></H4><!--SEC END -->
 
725
 
 
726
<A NAME="Streicher"></A>
 
727
Streicher's axiom <I>K</I> [<A HREF="#HofStr98"><CITE>12</CITE></A>] asserts dependent
 
728
elimination of reflexive equality proofs.<BR>
 
729
<BR>
 
730
 
 
731
<DIV ALIGN=left>
 
732
<TT>Coq&nbsp;&lt;&nbsp;Axiom&nbsp;Streicher_K&nbsp;:</TT><BR>
 
733
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;(A:Type)&nbsp;(x:A)&nbsp;(P:&nbsp;x=x&nbsp;-&gt;&nbsp;Prop),</TT><BR>
 
734
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P&nbsp;(refl_equal&nbsp;x)&nbsp;-&gt;&nbsp;forall&nbsp;p:&nbsp;x=x,&nbsp;P&nbsp;p.</TT><BR>
 
735
</DIV>
 
736
<BR>
 
737
In the general case, axiom <I>K</I> is an independent statement of the
 
738
Calculus of Inductive Constructions. However, it is true on decidable
 
739
domains (see file <A HREF="http://coq.inria.fr/library/Coq.Logic.Eqdep_dec.html
 
740
"><TT>Eqdep_dec.v</TT></A>). It is also
 
741
trivially a consequence of proof-irrelevance (see
 
742
<A HREF="#proof-irrelevance">34</A>) hence of classical logic.<BR>
 
743
<BR>
 
744
Axiom <I>K</I> is equivalent to <EM>Uniqueness of Identity Proofs</EM> [<A HREF="#HofStr98"><CITE>12</CITE></A>]<BR>
 
745
<BR>
 
746
 
 
747
<DIV ALIGN=left>
 
748
<TT>Coq&nbsp;&lt;&nbsp;Axiom&nbsp;UIP&nbsp;:&nbsp;forall&nbsp;(A:Set)&nbsp;(x&nbsp;y:A)&nbsp;(p1&nbsp;p2:&nbsp;x=y),&nbsp;p1&nbsp;=&nbsp;p2.</TT><BR>
 
749
</DIV>
 
750
<BR>
 
751
Axiom <I>K</I> is also equivalent to <EM>Uniqueness of Reflexive Identity Proofs</EM> [<A HREF="#HofStr98"><CITE>12</CITE></A>]<BR>
 
752
<BR>
 
753
 
 
754
<DIV ALIGN=left>
 
755
<TT>Coq&nbsp;&lt;&nbsp;Axiom&nbsp;UIP_refl&nbsp;:&nbsp;forall&nbsp;(A:Set)&nbsp;(x:A)&nbsp;(p:&nbsp;x=x),&nbsp;p&nbsp;=&nbsp;refl_equal&nbsp;x.</TT><BR>
 
756
</DIV>
 
757
<BR>
 
758
Axiom <I>K</I> is also equivalent to <BR>
 
759
<BR>
 
760
 
 
761
<DIV ALIGN=left>
 
762
<TT>Coq&nbsp;&lt;&nbsp;Axiom</TT><BR>
 
763
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;eq_rec_eq&nbsp;:</TT><BR>
 
764
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;(A:Set)&nbsp;(x:A)&nbsp;(P:&nbsp;A-&gt;Set)&nbsp;(p:P&nbsp;x)&nbsp;(h:&nbsp;x=x),</TT><BR>
 
765
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;eq_rect&nbsp;x&nbsp;P&nbsp;p&nbsp;x&nbsp;h.</TT><BR>
 
766
</DIV>
 
767
<BR>
 
768
It is also equivalent to the injectivity of dependent equality (dependent equality is itself equivalent to equality of dependent pairs).<BR>
 
769
<BR>
 
770
 
 
771
<DIV ALIGN=left>
 
772
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;eq_dep&nbsp;(U:Set)&nbsp;(P:U&nbsp;-&gt;&nbsp;Set)&nbsp;(p:U)&nbsp;(x:P&nbsp;p)&nbsp;:</TT><BR>
 
773
<TT>Coq&nbsp;&lt;&nbsp;forall&nbsp;q:U,&nbsp;P&nbsp;q&nbsp;-&gt;&nbsp;Prop&nbsp;:=</TT><BR>
 
774
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eq_dep_intro&nbsp;:&nbsp;eq_dep&nbsp;U&nbsp;P&nbsp;p&nbsp;x&nbsp;p&nbsp;x.</TT><BR>
 
775
<BR>
 
776
<TT>Coq&nbsp;&lt;&nbsp;Axiom</TT><BR>
 
777
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;eq_dep_eq&nbsp;:</TT><BR>
 
778
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;(U:Set)&nbsp;(u:U)&nbsp;(P:U&nbsp;-&gt;&nbsp;Set)&nbsp;(p1&nbsp;p2:P&nbsp;u),</TT><BR>
 
779
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eq_dep&nbsp;U&nbsp;P&nbsp;u&nbsp;p1&nbsp;u&nbsp;p2&nbsp;-&gt;&nbsp;p1&nbsp;=&nbsp;p2.</TT><BR>
 
780
</DIV>
 
781
<BR>
 
782
<!--TOC subsubsection What is proof-irrelevance-->
 
783
 
 
784
<H4><A NAME="htoc41">34</A>&nbsp;&nbsp;What is proof-irrelevance</H4><!--SEC END -->
 
785
 
 
786
<A NAME="proof-irrelevance"></A>
 
787
A specificity of the Calculus of Inductive Constructions is to permit
 
788
statements about proofs. This leads to the question of comparing two
 
789
proofs of the same proposition. Identifying all proofs of the same
 
790
proposition is called <EM>proof-irrelevance</EM>:
 
791
<DIV ALIGN=center>for all <I>A</I>:<TT><I>Prop</I></TT>, for all <I>p</I> <I>q</I>:<I>A</I>, <I>p</I>=<I>q</I>
 
792
</DIV> <BR>
 
793
Proof-irrelevance (in <TT>Prop</TT>) can be assumed without contradiction in
 
794
<FONT COLOR=navy>Coq</FONT>. It corresponds to a model where provability, whatever the
 
795
proof is, is more important than the computational content of the
 
796
proof. This is in harmony with the common purely logical
 
797
interpretation of <TT>Prop</TT>. Contrastingly, proof-irrelevance is
 
798
inconsistent in <TT>Set</TT> in harmony with the computational meaning of
 
799
the sort <TT>Set</TT>.<BR>
 
800
<BR>
 
801
Proof-irrelevance (in <TT>Prop</TT>) is a consequence of classical logic
 
802
(see proofs in file <A HREF="http://coq.inria.fr/library/Coq.Logic.Classical.html
 
803
"><TT>Classical.v</TT></A> and
 
804
<A HREF="http://coq.inria.fr/library/Coq.Logic.Berardi.html
 
805
"><TT>Berardi.v</TT></A>). Proof-irrelevance is also a
 
806
consequence of propositional extensionality (i.e. <TT>(A &lt;-&gt; B)
 
807
-&gt; A=B</TT>, see the proof in file
 
808
<A HREF="http://coq.inria.fr/library/Coq.Logic.ClassicalFacts.html
 
809
"><TT>ClassicalFacts.v</TT></A>).<BR>
 
810
<BR>
 
811
Conversely, proof-irrelevance directly implies Streicher's axiom <I>K</I>.<BR>
 
812
<BR>
 
813
<!--TOC subsubsection What about functional extensionality?-->
 
814
 
 
815
<H4><A NAME="htoc42">35</A>&nbsp;&nbsp;What about functional extensionality?</H4><!--SEC END -->
 
816
 
 
817
Extensionality of functions is an axiom in, say set theory, but from a
 
818
programing point of view, extensionality cannot be <EM>a priori</EM>
 
819
accepted since it would identify, say programs such as mergesort and
 
820
quicksort.<BR>
 
821
<BR>
 
822
Let <TT>A</TT>, <TT>B</TT> be types. To deal with extensionality on 
 
823
<CODE>A-&gt;B</CODE>, the recommended approach is to define one's
 
824
own extensional equality on <CODE>A-&gt;B</CODE>.<BR>
 
825
<BR>
 
826
 
 
827
<DIV ALIGN=left>
 
828
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;ext_eq&nbsp;(f&nbsp;g:&nbsp;A-&gt;B)&nbsp;:=&nbsp;forall&nbsp;x:A,&nbsp;f&nbsp;x&nbsp;=&nbsp;g&nbsp;x.</TT><BR>
 
829
</DIV>
 
830
<BR>
 
831
and to reason on <CODE>A-&gt;B</CODE> as a setoid (see the Chapter on
 
832
Setoids in the Reference Manual).<BR>
 
833
<BR>
 
834
<!--TOC subsubsection Is <TT>Prop</TT> impredicative?-->
 
835
 
 
836
<H4><A NAME="htoc43">36</A>&nbsp;&nbsp;Is <TT>Prop</TT> impredicative?</H4><!--SEC END -->
 
837
 
 
838
Yes, the sort <TT>Prop</TT> of propositions is <EM>impredicative</EM>. Otherwise said, a statement of the form for all
 
839
<I>A</I>:<I>Prop</I>, <I>P</I>(<I>A</I>) can be instantiated by itself: if for all <I>A</I>:<TT><I>Prop</I></TT>, <I>P</I>(<I>A</I>)
 
840
is provable, then <I>P</I>(for all <I>A</I>:<TT><I>Prop</I></TT>, <I>P</I>(<I>A</I>)) is.<BR>
 
841
<BR>
 
842
<!--TOC subsubsection Is <TT>Set</TT> impredicative?-->
 
843
 
 
844
<H4><A NAME="htoc44">37</A>&nbsp;&nbsp;Is <TT>Set</TT> impredicative?</H4><!--SEC END -->
 
845
 
 
846
No, the sort <TT>Set</TT> lying at the bottom of the hierarchy of
 
847
computational types is <EM>predicative</EM> in the basic <FONT COLOR=navy>Coq</FONT> system.
 
848
This means that a family of types in <TT>Set</TT>, e.g. for all <I>A</I>:<TT><I>Set</I></TT>, <I>A</I>
 
849
-&gt; <I>A</I>, is not a type in <TT>Set</TT> and it cannot be applied on
 
850
itself.<BR>
 
851
<BR>
 
852
However, the sort <TT>Set</TT> was impredicative in the original versions of
 
853
<FONT COLOR=navy>Coq</FONT>. For backward compatibility, or for experiments by
 
854
knowledgeable users, the logic of <FONT COLOR=navy>Coq</FONT> can be set impredicative for
 
855
<TT>Set</TT> by calling <FONT COLOR=navy>Coq</FONT> with the option <TT>-impredicative-set</TT>.<BR>
 
856
<BR>
 
857
<TT>Set</TT> has been made predicative from version 8.0 of <FONT COLOR=navy>Coq</FONT>. The main
 
858
reason is to interact smoothly with a classical mathematical world
 
859
where both excluded-middle and the axiom of description are valid (see
 
860
file <A HREF="http://coq.inria.fr/library/Coq.Logic.ClassicalDescription.html
 
861
"><TT>ClassicalDescription.v</TT></A> for a
 
862
proof that excluded-middle and description implies the double negation
 
863
of excluded-middle in <TT>Set</TT> and file <TT>Hurkens_Set.v</TT> from the
 
864
user contribution <TT>Rocq/PARADOXES</TT> for a proof that
 
865
impredicativity of <TT>Set</TT> implies the simple negation of
 
866
excluded-middle in <TT>Set</TT>).<BR>
 
867
<BR>
 
868
<!--TOC subsubsection Is <TT>Type</TT> impredicative?-->
 
869
 
 
870
<H4><A NAME="htoc45">38</A>&nbsp;&nbsp;Is <TT>Type</TT> impredicative?</H4><!--SEC END -->
 
871
 
 
872
No, <TT>Type</TT> is stratified. This is hidden for the
 
873
user, but <FONT COLOR=navy>Coq</FONT> internally maintains a set of constraints ensuring
 
874
stratification.<BR>
 
875
<BR>
 
876
If <TT>Type</TT> were impredicative then it would be possible to encode
 
877
Girard's systems <I>U</I>- and <I>U</I> in <FONT COLOR=navy>Coq</FONT> and it is known from Girard,
 
878
Coquand, Hurkens and Miquel that systems <I>U</I>- and <I>U</I> are inconsistent
 
879
[Girard 1972, Coquand 1991, Hurkens 1993, Miquel 2001]. This encoding
 
880
can be found in file <TT>Logic/Hurkens.v</TT> of <FONT COLOR=navy>Coq</FONT> standard library.<BR>
 
881
<BR>
 
882
For instance, when the user see <TT>for all X:Type, X-&gt;X : Type</TT>, each
 
883
occurrence of <TT>Type</TT> is implicitly bound to a different level, say
 
884
alpha and beta and the actual statement is <TT>forall X:Type(alpha), X-&gt;X : Type(beta)</TT> with the constraint
 
885
alpha&lt;beta.<BR>
 
886
<BR>
 
887
When a statement violates a constraint, the message <TT>Universe
 
888
inconsistency</TT> appears. Example: <TT>fun (x:Type) (y:for all X:Type, X
 
889
-&gt; X) =&gt; y x x</TT>.<BR>
 
890
<BR>
 
891
<!--TOC subsubsection I have two proofs of the same proposition. Can I prove they are equal?-->
 
892
 
 
893
<H4><A NAME="htoc46">39</A>&nbsp;&nbsp;I have two proofs of the same proposition. Can I prove they are equal?</H4><!--SEC END -->
 
894
 
 
895
In the base <FONT COLOR=navy>Coq</FONT> system, the answer is generally no. However, if
 
896
classical logic is set, the answer is yes for propositions in <TT>Prop</TT>.
 
897
The answer is also yes if proof irrelevance holds (see question
 
898
<A HREF="#proof-irrelevance">34</A>).<BR>
 
899
<BR>
 
900
There are also ``simple enough'' propositions for which you can prove
 
901
the equality without requiring any extra axioms. This is typically
 
902
the case for propositions defined deterministically as a first-order
 
903
inductive predicate on decidable sets. See for instance in question
 
904
<A HREF="#le-uniqueness">136</A> an axiom-free proof of the unicity of the proofs of
 
905
the proposition <TT>le m n</TT> (less or equal on <TT>nat</TT>).<BR>
 
906
<BR>
 
907
<!--TOC subsubsection I have two proofs of an equality statement. Can I prove they are 
 
908
equal?-->
 
909
 
 
910
<H4><A NAME="htoc47">40</A>&nbsp;&nbsp;I have two proofs of an equality statement. Can I prove they are 
 
911
equal?</H4><!--SEC END -->
 
912
 
 
913
Yes, if equality is decidable on the domain considered (which
 
914
is the case for <TT>nat</TT>, <TT>bool</TT>, etc): see <FONT COLOR=navy>Coq</FONT> file
 
915
<CODE>Eqdep_dec.v</CODE>). No otherwise, unless
 
916
assuming Streicher's axiom <I>K</I> (see [<A HREF="#HofStr98"><CITE>12</CITE></A>]) or a more general
 
917
assumption such as proof-irrelevance (see <A HREF="#proof-irrelevance">34</A>) or
 
918
classical logic.<BR>
 
919
<BR>
 
920
All of these statements can be found in file <A HREF="http://coq.inria.fr/library/Coq.Logic.Eqdep.html
 
921
"><TT>Eqdep.v</TT></A>.<BR>
 
922
<BR>
 
923
<!--TOC subsubsection Can I prove that the second components of equal dependent
 
924
pairs are equal?-->
 
925
 
 
926
<H4><A NAME="htoc48">41</A>&nbsp;&nbsp;Can I prove that the second components of equal dependent
 
927
pairs are equal?</H4><!--SEC END -->
 
928
 
 
929
The answer is the same as for proofs of equality
 
930
statements. It is provable if equality on the domain of the first
 
931
component is decidable (look at <CODE>inj_right_pair</CODE> from file
 
932
<A HREF="http://coq.inria.fr/library/Coq.Logic.Eqdep_dec.html
 
933
"><TT>Eqdep_dec.v</TT></A>), but not provable in the general
 
934
case. However, it is consistent (with the Calculus of Constructions)
 
935
to assume it is true. The file <A HREF="http://coq.inria.fr/library/Coq.Logic.Eqdep.html
 
936
"><TT>Eqdep.v</TT></A> actually
 
937
provides an axiom (equivalent to Streicher's axiom <I>K</I>) which entails
 
938
the result (look at <CODE>inj_pair2</CODE> in <A HREF="http://coq.inria.fr/library/Coq.Logic.Eqdep.html
 
939
"><TT>Eqdep.v</TT></A>).<BR>
 
940
<BR>
 
941
<!--TOC subsection Impredicativity-->
 
942
 
 
943
<H3><A NAME="htoc49">5.3</A>&nbsp;&nbsp;Impredicativity</H3><!--SEC END -->
 
944
 
 
945
<!--TOC subsubsection Why <TT>injection</TT> does not work on impredicative <TT>Set</TT>?-->
 
946
 
 
947
<H4><A NAME="htoc50">42</A>&nbsp;&nbsp;Why <TT>injection</TT> does not work on impredicative <TT>Set</TT>?</H4><!--SEC END -->
 
948
 
 
949
E.g. in this case (this occurs only in the <TT>Set</TT>-impredicative
 
950
 variant of <FONT COLOR=navy>Coq</FONT>):<BR>
 
951
<BR>
 
952
 
 
953
<DIV ALIGN=left>
 
954
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;I&nbsp;:&nbsp;Type&nbsp;:=</TT><BR>
 
955
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;intro&nbsp;:&nbsp;forall&nbsp;k:Set,&nbsp;k&nbsp;-&gt;&nbsp;I.</TT><BR>
 
956
<BR>
 
957
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;eq_jdef&nbsp;:&nbsp;</TT><BR>
 
958
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y:nat,&nbsp;intro&nbsp;_&nbsp;x&nbsp;=&nbsp;intro&nbsp;_&nbsp;y&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;y.</TT><BR>
 
959
<BR>
 
960
<TT>Coq&nbsp;&lt;&nbsp;Proof.</TT><BR>
 
961
<BR>
 
962
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;intros&nbsp;x&nbsp;y&nbsp;H;&nbsp;injection&nbsp;H.</TT><BR>
 
963
</DIV>
 
964
<BR>
 
965
Injectivity of constructors is restricted to predicative types. If
 
966
injectivity on large inductive types were not restricted, we would be
 
967
allowed to derive an inconsistency (e.g. following the lines of
 
968
Burali-Forti paradox). The question remains open whether injectivity
 
969
is consistent on some large inductive types not expressive enough to
 
970
encode known paradoxes (such as type I above).<BR>
 
971
<BR>
 
972
<!--TOC subsubsection What is a "large inductive definition"?-->
 
973
 
 
974
<H4><A NAME="htoc51">43</A>&nbsp;&nbsp;What is a "large inductive definition"?</H4><!--SEC END -->
 
975
 
 
976
An inductive definition in <TT>Prop</TT> pr <TT>Set</TT> is called large
 
977
if its constructors embed sets or propositions. As an example, here is
 
978
a large inductive type:<BR>
 
979
<BR>
 
980
 
 
981
<DIV ALIGN=left>
 
982
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;sigST&nbsp;(P:Set&nbsp;-&gt;&nbsp;Set)&nbsp;:&nbsp;Type&nbsp;:=</TT><BR>
 
983
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;existST&nbsp;:&nbsp;forall&nbsp;X:Set,&nbsp;P&nbsp;X&nbsp;-&gt;&nbsp;sigST&nbsp;P.</TT><BR>
 
984
</DIV>
 
985
<BR>
 
986
In the <TT>Set</TT> impredicative variant of <FONT COLOR=navy>Coq</FONT>, large inductive
 
987
definitions in <TT>Set</TT> have restricted elimination schemes to
 
988
prevent inconsistencies. Especially, projecting the set or the
 
989
proposition content of a large inductive definition is forbidden. If
 
990
it were allowed, it would be possible to encode e.g. Burali-Forti
 
991
paradox [<A HREF="#Gir70"><CITE>9</CITE></A><CITE>, </CITE><A HREF="#Coq85"><CITE>4</CITE></A>].<BR>
 
992
<BR>
 
993
<!--TOC section Talkin' with the Rooster-->
 
994
 
 
995
<H2><A NAME="htoc52">6</A>&nbsp;&nbsp;Talkin' with the Rooster</H2><!--SEC END -->
 
996
 
 
997
<!--TOC subsection My goal is ..., how can I prove it?-->
 
998
 
 
999
<H3><A NAME="htoc53">6.1</A>&nbsp;&nbsp;My goal is ..., how can I prove it?</H3><!--SEC END -->
 
1000
 
 
1001
<!--TOC subsubsection My goal is a conjunction, how can I prove it?-->
 
1002
 
 
1003
<H4><A NAME="htoc54">44</A>&nbsp;&nbsp;My goal is a conjunction, how can I prove it?</H4><!--SEC END -->
 
1004
 
 
1005
Use some theorem or assumption or use the <TT>split</TT> tactic.
 
1006
 
 
1007
<DIV ALIGN=left>
 
1008
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B:Prop,&nbsp;A-&gt;B-&gt;&nbsp;A/\B.</TT><BR>
 
1009
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1010
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1011
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1012
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;B&nbsp;-&gt;&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
1013
<BR>
 
1014
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1015
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1016
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1017
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1018
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1019
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
1020
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
1021
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1022
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
1023
<BR>
 
1024
<TT>Coq&nbsp;&lt;&nbsp;split.</TT><BR>
 
1025
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
1026
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1027
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1028
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1029
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
1030
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
1031
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1032
<TT><I>&nbsp;&nbsp;&nbsp;A</I></TT><BR>
 
1033
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
1034
<TT><I>&nbsp;B</I></TT><BR>
 
1035
<BR>
 
1036
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1037
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1038
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1039
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1040
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1041
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
1042
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
1043
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1044
<TT><I>&nbsp;&nbsp;&nbsp;B</I></TT><BR>
 
1045
<BR>
 
1046
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1047
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1048
<BR>
 
1049
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1050
<TT><I>intros.</I></TT><BR>
 
1051
<TT><I>split.</I></TT><BR>
 
1052
<TT><I>&nbsp;assumption.</I></TT><BR>
 
1053
<TT><I>&nbsp;assumption.</I></TT><BR>
 
1054
<TT><I>Unnamed_thm&nbsp;is&nbsp;defined</I></TT><BR>
 
1055
</DIV>
 
1056
<BR>
 
1057
<!--TOC subsubsection My goal contains a conjunction as an hypothesis, how can I use it?-->
 
1058
 
 
1059
<H4><A NAME="htoc55">45</A>&nbsp;&nbsp;My goal contains a conjunction as an hypothesis, how can I use it?</H4><!--SEC END -->
 
1060
 
 
1061
If you want to decompose your hypothesis into other hypothesis you can use the <TT>decompose</TT> tactic:<BR>
 
1062
<BR>
 
1063
 
 
1064
<DIV ALIGN=left>
 
1065
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B:Prop,&nbsp;A/\B-&gt;&nbsp;B.</TT><BR>
 
1066
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1067
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1068
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1069
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;/\&nbsp;B&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
1070
<BR>
 
1071
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1072
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1073
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1074
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1075
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1076
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
1077
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1078
<TT><I>&nbsp;&nbsp;&nbsp;B</I></TT><BR>
 
1079
<BR>
 
1080
<TT>Coq&nbsp;&lt;&nbsp;decompose&nbsp;[and]&nbsp;H.</TT><BR>
 
1081
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1082
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1083
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1084
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1085
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
1086
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;A</I></TT><BR>
 
1087
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;B</I></TT><BR>
 
1088
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1089
<TT><I>&nbsp;&nbsp;&nbsp;B</I></TT><BR>
 
1090
<BR>
 
1091
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1092
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1093
<BR>
 
1094
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1095
<TT><I>intros.</I></TT><BR>
 
1096
<TT><I>decompose&nbsp;[and]&nbsp;H.</I></TT><BR>
 
1097
<TT><I>assumption.</I></TT><BR>
 
1098
<TT><I>Unnamed_thm0&nbsp;is&nbsp;defined</I></TT><BR>
 
1099
</DIV>
 
1100
<BR>
 
1101
<!--TOC subsubsection My goal is a disjunction, how can I prove it?-->
 
1102
 
 
1103
<H4><A NAME="htoc56">46</A>&nbsp;&nbsp;My goal is a disjunction, how can I prove it?</H4><!--SEC END -->
 
1104
 
 
1105
You can prove the left part or the right part of the disjunction using
 
1106
<TT>left</TT> or <TT>right</TT> tactics. If you want to do a classical
 
1107
reasoning step, use the <TT>classic</TT> axiom to prove the right part with the assumption
 
1108
that the left part of the disjunction is false.<BR>
 
1109
<BR>
 
1110
 
 
1111
<DIV ALIGN=left>
 
1112
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B:Prop,&nbsp;A-&gt;&nbsp;A\/B.</TT><BR>
 
1113
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1114
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1115
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1116
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;A&nbsp;\/&nbsp;B</I></TT><BR>
 
1117
<BR>
 
1118
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1119
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1120
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1121
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1122
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1123
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
1124
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1125
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;\/&nbsp;B</I></TT><BR>
 
1126
<BR>
 
1127
<TT>Coq&nbsp;&lt;&nbsp;left.</TT><BR>
 
1128
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1129
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1130
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1131
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1132
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
1133
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1134
<TT><I>&nbsp;&nbsp;&nbsp;A</I></TT><BR>
 
1135
<BR>
 
1136
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1137
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1138
<BR>
 
1139
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1140
<TT><I>intros.</I></TT><BR>
 
1141
<TT><I>left.</I></TT><BR>
 
1142
<TT><I>assumption.</I></TT><BR>
 
1143
<TT><I>Unnamed_thm1&nbsp;is&nbsp;defined</I></TT><BR>
 
1144
</DIV>
 
1145
<BR>
 
1146
An example using classical reasoning:<BR>
 
1147
<BR>
 
1148
 
 
1149
<DIV ALIGN=left>
 
1150
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;Classical.</TT><BR>
 
1151
<BR>
 
1152
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1153
<TT>Coq&nbsp;&lt;&nbsp;Ltac&nbsp;classical_right&nbsp;:=&nbsp;</TT><BR>
 
1154
<TT>Coq&nbsp;&lt;&nbsp;match&nbsp;goal&nbsp;with&nbsp;</TT><BR>
 
1155
<TT>Coq&nbsp;&lt;&nbsp;|&nbsp;_:_&nbsp;|-?X1&nbsp;\/&nbsp;_&nbsp;=&gt;&nbsp;(elim&nbsp;(classic&nbsp;X1);intro;[left;trivial|right])</TT><BR>
 
1156
<TT>Coq&nbsp;&lt;&nbsp;end.</TT><BR>
 
1157
<TT><I>classical_right&nbsp;is&nbsp;defined</I></TT><BR>
 
1158
<BR>
 
1159
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1160
<TT>Coq&nbsp;&lt;&nbsp;Ltac&nbsp;classical_left&nbsp;:=&nbsp;</TT><BR>
 
1161
<TT>Coq&nbsp;&lt;&nbsp;match&nbsp;goal&nbsp;with&nbsp;</TT><BR>
 
1162
<TT>Coq&nbsp;&lt;&nbsp;|&nbsp;_:_&nbsp;|-&nbsp;_&nbsp;\/?X1&nbsp;=&gt;&nbsp;(elim&nbsp;(classic&nbsp;X1);intro;[right;trivial|left])</TT><BR>
 
1163
<TT>Coq&nbsp;&lt;&nbsp;end.</TT><BR>
 
1164
<TT><I>classical_left&nbsp;is&nbsp;defined</I></TT><BR>
 
1165
<BR>
 
1166
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1167
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1168
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B:Prop,&nbsp;(~A&nbsp;-&gt;&nbsp;B)&nbsp;-&gt;&nbsp;A\/B.</TT><BR>
 
1169
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1170
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1171
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1172
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;(~&nbsp;A&nbsp;-&gt;&nbsp;B)&nbsp;-&gt;&nbsp;A&nbsp;\/&nbsp;B</I></TT><BR>
 
1173
<BR>
 
1174
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1175
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1176
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1177
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1178
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1179
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;~&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
1180
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1181
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;\/&nbsp;B</I></TT><BR>
 
1182
<BR>
 
1183
<TT>Coq&nbsp;&lt;&nbsp;classical_right.</TT><BR>
 
1184
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1185
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1186
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1187
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1188
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;~&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
1189
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;~&nbsp;A</I></TT><BR>
 
1190
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1191
<TT><I>&nbsp;&nbsp;&nbsp;B</I></TT><BR>
 
1192
<BR>
 
1193
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
1194
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1195
<BR>
 
1196
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1197
<TT><I>intros.</I></TT><BR>
 
1198
<TT><I>classical_right.</I></TT><BR>
 
1199
<TT><I>auto.</I></TT><BR>
 
1200
<TT><I>Unnamed_thm2&nbsp;is&nbsp;defined</I></TT><BR>
 
1201
</DIV>
 
1202
<BR>
 
1203
<!--TOC subsubsection My goal is an universally quantified statement, how can I prove it?-->
 
1204
 
 
1205
<H4><A NAME="htoc57">47</A>&nbsp;&nbsp;My goal is an universally quantified statement, how can I prove it?</H4><!--SEC END -->
 
1206
 
 
1207
Use some theorem or assumption or introduce the quantified variable in
 
1208
the context using the <TT>intro</TT> tactic. If there are several
 
1209
variables you can use the <TT>intros</TT> tactic. A good habit is to
 
1210
provide names for these variables: <FONT COLOR=navy>Coq</FONT> will do it anyway, but such
 
1211
automatic naming decreases legibility and robustness.<BR>
 
1212
<BR>
 
1213
<!--TOC subsubsection My goal is an existential, how can I prove it?-->
 
1214
 
 
1215
<H4><A NAME="htoc58">48</A>&nbsp;&nbsp;My goal is an existential, how can I prove it?</H4><!--SEC END -->
 
1216
 
 
1217
Use some theorem or assumption or exhibit the witness using the <TT>exists</TT> tactic.
 
1218
 
 
1219
<DIV ALIGN=left>
 
1220
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;exists&nbsp;x:nat,&nbsp;forall&nbsp;y,&nbsp;x+y=y.</TT><BR>
 
1221
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1222
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1223
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1224
<TT><I>&nbsp;&nbsp;&nbsp;exists&nbsp;x&nbsp;:&nbsp;nat,&nbsp;(forall&nbsp;y&nbsp;:&nbsp;nat,&nbsp;x&nbsp;+&nbsp;y&nbsp;=&nbsp;y)</I></TT><BR>
 
1225
<BR>
 
1226
<TT>Coq&nbsp;&lt;&nbsp;exists&nbsp;0.</TT><BR>
 
1227
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1228
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1229
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1230
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;y&nbsp;:&nbsp;nat,&nbsp;0&nbsp;+&nbsp;y&nbsp;=&nbsp;y</I></TT><BR>
 
1231
<BR>
 
1232
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1233
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1234
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1235
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1236
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1237
<TT><I>&nbsp;&nbsp;&nbsp;0&nbsp;+&nbsp;y&nbsp;=&nbsp;y</I></TT><BR>
 
1238
<BR>
 
1239
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
1240
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1241
<BR>
 
1242
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1243
<TT><I>exists&nbsp;0.</I></TT><BR>
 
1244
<TT><I>intros.</I></TT><BR>
 
1245
<TT><I>auto.</I></TT><BR>
 
1246
<TT><I>Unnamed_thm3&nbsp;is&nbsp;defined</I></TT><BR>
 
1247
</DIV>
 
1248
<BR>
 
1249
<!--TOC subsubsection My goal is solvable by some lemma, how can I prove it?-->
 
1250
 
 
1251
<H4><A NAME="htoc59">49</A>&nbsp;&nbsp;My goal is solvable by some lemma, how can I prove it?</H4><!--SEC END -->
 
1252
 
 
1253
Just use the <TT>apply</TT> tactic.<BR>
 
1254
<BR>
 
1255
 
 
1256
<DIV ALIGN=left>
 
1257
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;mylemma&nbsp;:&nbsp;forall&nbsp;x,&nbsp;x+0&nbsp;=&nbsp;x.</TT><BR>
 
1258
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1259
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1260
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1261
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;:&nbsp;nat,&nbsp;x&nbsp;+&nbsp;0&nbsp;=&nbsp;x</I></TT><BR>
 
1262
<BR>
 
1263
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
1264
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1265
<BR>
 
1266
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1267
<TT><I>auto.</I></TT><BR>
 
1268
<TT><I>mylemma&nbsp;is&nbsp;defined</I></TT><BR>
 
1269
<BR>
 
1270
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1271
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;3+0&nbsp;=&nbsp;3.</TT><BR>
 
1272
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1273
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1274
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1275
<TT><I>&nbsp;&nbsp;&nbsp;3&nbsp;+&nbsp;0&nbsp;=&nbsp;3</I></TT><BR>
 
1276
<BR>
 
1277
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;mylemma.</TT><BR>
 
1278
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1279
<BR>
 
1280
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1281
<TT><I>apply&nbsp;mylemma.</I></TT><BR>
 
1282
<TT><I>Unnamed_thm&nbsp;is&nbsp;defined</I></TT><BR>
 
1283
</DIV>
 
1284
<BR>
 
1285
<!--TOC subsubsection My goal contains False as an hypotheses, how can I prove it?-->
 
1286
 
 
1287
<H4><A NAME="htoc60">50</A>&nbsp;&nbsp;My goal contains False as an hypotheses, how can I prove it?</H4><!--SEC END -->
 
1288
 
 
1289
You can use the <TT>contradiction</TT> or <TT>intuition</TT> tactics.<BR>
 
1290
<BR>
 
1291
<!--TOC subsubsection My goal is an equality of two convertible terms, how can I prove it?-->
 
1292
 
 
1293
<H4><A NAME="htoc61">51</A>&nbsp;&nbsp;My goal is an equality of two convertible terms, how can I prove it?</H4><!--SEC END -->
 
1294
 
 
1295
Just use the <TT>reflexivity</TT> tactic.<BR>
 
1296
<BR>
 
1297
 
 
1298
<DIV ALIGN=left>
 
1299
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x,&nbsp;0+x&nbsp;=&nbsp;x.</TT><BR>
 
1300
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1301
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1302
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1303
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;:&nbsp;nat,&nbsp;0&nbsp;+&nbsp;x&nbsp;=&nbsp;x</I></TT><BR>
 
1304
<BR>
 
1305
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1306
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1307
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1308
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1309
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1310
<TT><I>&nbsp;&nbsp;&nbsp;0&nbsp;+&nbsp;x&nbsp;=&nbsp;x</I></TT><BR>
 
1311
<BR>
 
1312
<TT>Coq&nbsp;&lt;&nbsp;reflexivity.</TT><BR>
 
1313
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1314
<BR>
 
1315
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1316
<TT><I>intros.</I></TT><BR>
 
1317
<TT><I>reflexivity.</I></TT><BR>
 
1318
<TT><I>Unnamed_thm0&nbsp;is&nbsp;defined</I></TT><BR>
 
1319
</DIV>
 
1320
<BR>
 
1321
<!--TOC subsubsection My goal is a <TT>let x := a in ...</TT>, how can I prove it?-->
 
1322
 
 
1323
<H4><A NAME="htoc62">52</A>&nbsp;&nbsp;My goal is a <TT>let x := a in ...</TT>, how can I prove it?</H4><!--SEC END -->
 
1324
 
 
1325
Just use the <TT>intro</TT> tactic.<BR>
 
1326
<BR>
 
1327
<!--TOC subsubsection My goal is a <TT>let (a, ..., b) := c in</TT>, how can I prove it?-->
 
1328
 
 
1329
<H4><A NAME="htoc63">53</A>&nbsp;&nbsp;My goal is a <TT>let (a, ..., b) := c in</TT>, how can I prove it?</H4><!--SEC END -->
 
1330
 
 
1331
Just use the <TT>destruct</TT> c as (a,...,b) tactic.<BR>
 
1332
<BR>
 
1333
<!--TOC subsubsection My goal contains some existential hypotheses, how can I use it?-->
 
1334
 
 
1335
<H4><A NAME="htoc64">54</A>&nbsp;&nbsp;My goal contains some existential hypotheses, how can I use it?</H4><!--SEC END -->
 
1336
 
 
1337
You can use the tactic <TT>elim</TT> with you hypotheses as an argument.<BR>
 
1338
<BR>
 
1339
<!--TOC subsubsection My goal contains some existential hypotheses, how can I use it and decompose my knowledge about this new thing into different hypotheses?-->
 
1340
 
 
1341
<H4><A NAME="htoc65">55</A>&nbsp;&nbsp;My goal contains some existential hypotheses, how can I use it and decompose my knowledge about this new thing into different hypotheses?</H4><!--SEC END -->
 
1342
 
 
1343
<PRE>
 
1344
Ltac DecompEx H P := elim H;intro P;intro TO;decompose [and] TO;clear TO;clear H.
 
1345
</PRE>
 
1346
<!--TOC subsubsection My goal is an equality, how can I swap the left and right hand terms?-->
 
1347
 
 
1348
<H4><A NAME="htoc66">56</A>&nbsp;&nbsp;My goal is an equality, how can I swap the left and right hand terms?</H4><!--SEC END -->
 
1349
 
 
1350
Just use the <TT>symmetry</TT> tactic.
 
1351
 
 
1352
<DIV ALIGN=left>
 
1353
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x&nbsp;y&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;y=x.</TT><BR>
 
1354
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1355
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1356
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1357
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;x</I></TT><BR>
 
1358
<BR>
 
1359
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1360
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1361
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1362
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1363
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1364
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1365
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1366
<TT><I>&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;x</I></TT><BR>
 
1367
<BR>
 
1368
<TT>Coq&nbsp;&lt;&nbsp;symmetry.</TT><BR>
 
1369
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1370
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1371
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1372
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1373
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1374
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1375
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1376
<BR>
 
1377
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1378
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1379
<BR>
 
1380
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1381
<TT><I>intros.</I></TT><BR>
 
1382
<TT><I>symmetry&nbsp;&nbsp;in&nbsp;|-&nbsp;*.</I></TT><BR>
 
1383
<TT><I>assumption.</I></TT><BR>
 
1384
<TT><I>Unnamed_thm1&nbsp;is&nbsp;defined</I></TT><BR>
 
1385
</DIV>
 
1386
<BR>
 
1387
<!--TOC subsubsection My hypothesis is an equality, how can I swap the left and right hand terms?-->
 
1388
 
 
1389
<H4><A NAME="htoc67">57</A>&nbsp;&nbsp;My hypothesis is an equality, how can I swap the left and right hand terms?</H4><!--SEC END -->
 
1390
 
 
1391
Just use the <TT>symmetryin</TT> tactic.<BR>
 
1392
<BR>
 
1393
 
 
1394
<DIV ALIGN=left>
 
1395
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x&nbsp;y&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;y=x.</TT><BR>
 
1396
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1397
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1398
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1399
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;x</I></TT><BR>
 
1400
<BR>
 
1401
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1402
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1403
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1404
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1405
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1406
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1407
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1408
<TT><I>&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;x</I></TT><BR>
 
1409
<BR>
 
1410
<TT>Coq&nbsp;&lt;&nbsp;symmetry&nbsp;in&nbsp;H.</TT><BR>
 
1411
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1412
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1413
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1414
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1415
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;y&nbsp;=&nbsp;x</I></TT><BR>
 
1416
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1417
<TT><I>&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;x</I></TT><BR>
 
1418
<BR>
 
1419
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1420
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1421
<BR>
 
1422
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1423
<TT><I>intros.</I></TT><BR>
 
1424
<TT><I>symmetry&nbsp;&nbsp;in&nbsp;H.</I></TT><BR>
 
1425
<TT><I>assumption.</I></TT><BR>
 
1426
<TT><I>Unnamed_thm2&nbsp;is&nbsp;defined</I></TT><BR>
 
1427
</DIV>
 
1428
<BR>
 
1429
<!--TOC subsubsection My goal is an equality, how can I prove it by transitivity?-->
 
1430
 
 
1431
<H4><A NAME="htoc68">58</A>&nbsp;&nbsp;My goal is an equality, how can I prove it by transitivity?</H4><!--SEC END -->
 
1432
 
 
1433
Just use the <TT>transitivity</TT> tactic.
 
1434
 
 
1435
<DIV ALIGN=left>
 
1436
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;y=z&nbsp;-&gt;&nbsp;x=z.</TT><BR>
 
1437
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1438
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1439
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1440
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;z&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1441
<BR>
 
1442
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1443
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1444
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1445
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1446
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1447
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1448
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1449
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1450
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1451
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1452
<BR>
 
1453
<TT>Coq&nbsp;&lt;&nbsp;transitivity&nbsp;y.</TT><BR>
 
1454
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
1455
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1456
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1457
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1458
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1459
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1460
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1461
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1462
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1463
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
1464
<TT><I>&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1465
<BR>
 
1466
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1467
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1468
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1469
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1470
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1471
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1472
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1473
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1474
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1475
<TT><I>&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1476
<BR>
 
1477
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1478
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1479
<BR>
 
1480
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1481
<TT><I>intros.</I></TT><BR>
 
1482
<TT><I>transitivity&nbsp;y.</I></TT><BR>
 
1483
<TT><I>&nbsp;assumption.</I></TT><BR>
 
1484
<TT><I>&nbsp;assumption.</I></TT><BR>
 
1485
<TT><I>Unnamed_thm3&nbsp;is&nbsp;defined</I></TT><BR>
 
1486
</DIV>
 
1487
<BR>
 
1488
<!--TOC subsubsection My goal would be solvable using <TT>apply;assumption</TT> if it would not create meta-variables, how can I prove it?-->
 
1489
 
 
1490
<H4><A NAME="htoc69">59</A>&nbsp;&nbsp;My goal would be solvable using <TT>apply;assumption</TT> if it would not create meta-variables, how can I prove it?</H4><!--SEC END -->
 
1491
 
 
1492
You can use <TT>eapply yourtheorem;eauto</TT> but it won't work in all cases ! (for example if more than one hypothesis match one of the subgoals generated by <TT>eapply</TT>) so you should rather use <TT>try solve [eapply yourtheorem;eauto]</TT>, otherwise some metavariables may be incorrectly instantiated.<BR>
 
1493
<BR>
 
1494
 
 
1495
<DIV ALIGN=left>
 
1496
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;trans&nbsp;:&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;y=z&nbsp;-&gt;&nbsp;x=z.</TT><BR>
 
1497
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1498
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1499
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1500
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;z&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1501
<BR>
 
1502
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1503
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1504
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1505
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1506
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1507
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1508
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1509
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1510
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1511
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1512
<BR>
 
1513
<TT>Coq&nbsp;&lt;&nbsp;transitivity&nbsp;y;assumption.</TT><BR>
 
1514
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1515
<BR>
 
1516
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1517
<TT><I>intros.</I></TT><BR>
 
1518
<TT><I>transitivity&nbsp;y;&nbsp;assumption.</I></TT><BR>
 
1519
<TT><I>trans&nbsp;is&nbsp;defined</I></TT><BR>
 
1520
<BR>
 
1521
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1522
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;y=z&nbsp;-&gt;&nbsp;x=z.</TT><BR>
 
1523
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1524
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1525
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1526
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;z&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1527
<BR>
 
1528
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1529
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1530
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1531
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1532
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1533
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1534
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1535
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1536
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1537
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1538
<BR>
 
1539
<TT>Coq&nbsp;&lt;&nbsp;eapply&nbsp;trans;eauto.</TT><BR>
 
1540
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1541
<BR>
 
1542
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1543
<TT><I>intros.</I></TT><BR>
 
1544
<TT><I>eapply&nbsp;trans;&nbsp;eauto.</I></TT><BR>
 
1545
<TT><I>Unnamed_thm4&nbsp;is&nbsp;defined</I></TT><BR>
 
1546
<BR>
 
1547
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1548
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;t&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;x=t&nbsp;-&gt;&nbsp;y=z&nbsp;-&gt;&nbsp;x=z.</TT><BR>
 
1549
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1550
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1551
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1552
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;t&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;t&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;z&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1553
<BR>
 
1554
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1555
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1556
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1557
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1558
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1559
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1560
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1561
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1562
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1563
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1564
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1565
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1566
<BR>
 
1567
<TT>Coq&nbsp;&lt;&nbsp;eapply&nbsp;trans;eauto.</TT><BR>
 
1568
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1569
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1570
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1571
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1572
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1573
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1574
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1575
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1576
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1577
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1578
<TT><I>&nbsp;&nbsp;&nbsp;t&nbsp;=&nbsp;z</I></TT><BR>
 
1579
<BR>
 
1580
<TT>Coq&nbsp;&lt;&nbsp;Undo.</TT><BR>
 
1581
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1582
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1583
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1584
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1585
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1586
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1587
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1588
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1589
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1590
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1591
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1592
<BR>
 
1593
<TT>Coq&nbsp;&lt;&nbsp;eapply&nbsp;trans.</TT><BR>
 
1594
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
1595
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1596
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1597
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1598
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1599
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1600
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1601
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1602
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1603
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1604
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;?47</I></TT><BR>
 
1605
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
1606
<TT><I>&nbsp;?47&nbsp;=&nbsp;z</I></TT><BR>
 
1607
<BR>
 
1608
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;H.</TT><BR>
 
1609
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1610
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1611
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1612
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1613
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1614
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1615
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1616
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1617
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1618
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1619
<TT><I>&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1620
<BR>
 
1621
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
1622
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1623
<BR>
 
1624
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1625
<TT><I>intros.</I></TT><BR>
 
1626
<TT><I>eapply&nbsp;trans.</I></TT><BR>
 
1627
<TT><I>&nbsp;apply&nbsp;H.</I></TT><BR>
 
1628
<TT><I>&nbsp;</I></TT><BR>
 
1629
<TT><I>&nbsp;&nbsp;&nbsp;auto.</I></TT><BR>
 
1630
<TT><I>Unnamed_thm5&nbsp;is&nbsp;defined</I></TT><BR>
 
1631
<BR>
 
1632
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1633
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;t&nbsp;:&nbsp;nat,&nbsp;x=y&nbsp;-&gt;&nbsp;x=t&nbsp;-&gt;&nbsp;y=z&nbsp;-&gt;&nbsp;x=z.</TT><BR>
 
1634
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1635
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1636
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1637
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;x&nbsp;y&nbsp;z&nbsp;t&nbsp;:&nbsp;nat,&nbsp;x&nbsp;=&nbsp;y&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;t&nbsp;-&gt;&nbsp;y&nbsp;=&nbsp;z&nbsp;-&gt;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1638
<BR>
 
1639
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1640
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1641
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1642
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1643
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1644
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1645
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1646
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1647
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1648
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1649
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1650
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1651
<BR>
 
1652
<TT>Coq&nbsp;&lt;&nbsp;eapply&nbsp;trans;eauto.</TT><BR>
 
1653
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1654
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1655
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1656
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1657
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1658
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1659
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1660
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1661
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1662
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1663
<TT><I>&nbsp;&nbsp;&nbsp;t&nbsp;=&nbsp;z</I></TT><BR>
 
1664
<BR>
 
1665
<TT>Coq&nbsp;&lt;&nbsp;Undo.</TT><BR>
 
1666
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1667
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1668
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1669
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1670
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1671
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1672
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1673
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1674
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1675
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1676
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1677
<BR>
 
1678
<TT>Coq&nbsp;&lt;&nbsp;try&nbsp;solve&nbsp;[eapply&nbsp;trans;eauto].</TT><BR>
 
1679
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1680
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1681
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1682
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1683
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1684
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1685
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1686
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1687
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1688
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1689
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;z</I></TT><BR>
 
1690
<BR>
 
1691
<TT>Coq&nbsp;&lt;&nbsp;eapply&nbsp;trans.</TT><BR>
 
1692
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
1693
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1694
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1695
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1696
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1697
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1698
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1699
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1700
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1701
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1702
<TT><I>&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;?54</I></TT><BR>
 
1703
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
1704
<TT><I>&nbsp;?54&nbsp;=&nbsp;z</I></TT><BR>
 
1705
<BR>
 
1706
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;H.</TT><BR>
 
1707
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1708
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1709
<TT><I>&nbsp;&nbsp;x&nbsp;:&nbsp;nat</I></TT><BR>
 
1710
<TT><I>&nbsp;&nbsp;y&nbsp;:&nbsp;nat</I></TT><BR>
 
1711
<TT><I>&nbsp;&nbsp;z&nbsp;:&nbsp;nat</I></TT><BR>
 
1712
<TT><I>&nbsp;&nbsp;t&nbsp;:&nbsp;nat</I></TT><BR>
 
1713
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;x&nbsp;=&nbsp;y</I></TT><BR>
 
1714
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;x&nbsp;=&nbsp;t</I></TT><BR>
 
1715
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1716
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1717
<TT><I>&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;z</I></TT><BR>
 
1718
<BR>
 
1719
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
1720
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1721
<BR>
 
1722
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1723
<TT><I>intros.</I></TT><BR>
 
1724
<TT><I>try&nbsp;solve&nbsp;[&nbsp;eapply&nbsp;trans;&nbsp;eauto&nbsp;].</I></TT><BR>
 
1725
<TT><I>eapply&nbsp;trans.</I></TT><BR>
 
1726
<TT><I>&nbsp;apply&nbsp;H.</I></TT><BR>
 
1727
<TT><I>&nbsp;</I></TT><BR>
 
1728
<TT><I>&nbsp;&nbsp;&nbsp;auto.</I></TT><BR>
 
1729
<TT><I>Unnamed_thm6&nbsp;is&nbsp;defined</I></TT><BR>
 
1730
<BR>
 
1731
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1732
</DIV>
 
1733
<BR>
 
1734
<!--TOC subsubsection My goal is solvable by some lemma within a set of lemmas and I don't want to remember which one, how can I prove it?-->
 
1735
 
 
1736
<H4><A NAME="htoc70">60</A>&nbsp;&nbsp;My goal is solvable by some lemma within a set of lemmas and I don't want to remember which one, how can I prove it?</H4><!--SEC END -->
 
1737
 
 
1738
You can use a what is called a hints' base.<BR>
 
1739
<BR>
 
1740
 
 
1741
<DIV ALIGN=left>
 
1742
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;ZArith.</TT><BR>
 
1743
<TT><I>Coq&nbsp;&lt;&nbsp;</I></TT><BR>
 
1744
<BR>
 
1745
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Ring.</TT><BR>
 
1746
<BR>
 
1747
<TT>Coq&nbsp;&lt;&nbsp;Open&nbsp;Local&nbsp;Scope&nbsp;Z_scope.</TT><BR>
 
1748
<BR>
 
1749
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;toto1&nbsp;:&nbsp;1+1&nbsp;=&nbsp;2.</TT><BR>
 
1750
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1751
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1752
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1753
<TT><I>&nbsp;&nbsp;&nbsp;1&nbsp;+&nbsp;1&nbsp;=&nbsp;2</I></TT><BR>
 
1754
<BR>
 
1755
<TT>Coq&nbsp;&lt;&nbsp;ring.</TT><BR>
 
1756
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1757
<BR>
 
1758
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1759
<TT><I>ring.</I></TT><BR>
 
1760
<TT><I>toto1&nbsp;is&nbsp;defined</I></TT><BR>
 
1761
<BR>
 
1762
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;toto2&nbsp;:&nbsp;2+2&nbsp;=&nbsp;4.</TT><BR>
 
1763
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1764
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1765
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1766
<TT><I>&nbsp;&nbsp;&nbsp;2&nbsp;+&nbsp;2&nbsp;=&nbsp;4</I></TT><BR>
 
1767
<BR>
 
1768
<TT>Coq&nbsp;&lt;&nbsp;ring.</TT><BR>
 
1769
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1770
<BR>
 
1771
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1772
<TT><I>ring.</I></TT><BR>
 
1773
<TT><I>toto2&nbsp;is&nbsp;defined</I></TT><BR>
 
1774
<BR>
 
1775
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;toto3&nbsp;:&nbsp;2+1&nbsp;=&nbsp;3.</TT><BR>
 
1776
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1777
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1778
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1779
<TT><I>&nbsp;&nbsp;&nbsp;2&nbsp;+&nbsp;1&nbsp;=&nbsp;3</I></TT><BR>
 
1780
<BR>
 
1781
<TT>Coq&nbsp;&lt;&nbsp;ring.</TT><BR>
 
1782
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1783
<BR>
 
1784
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1785
<TT><I>ring.</I></TT><BR>
 
1786
<TT><I>toto3&nbsp;is&nbsp;defined</I></TT><BR>
 
1787
<BR>
 
1788
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1789
<TT>Coq&nbsp;&lt;&nbsp;Hint&nbsp;Resolve&nbsp;toto1&nbsp;toto2&nbsp;toto3&nbsp;:&nbsp;mybase.</TT><BR>
 
1790
<BR>
 
1791
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
1792
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;2+(1+1)=4.&nbsp;</TT><BR>
 
1793
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1794
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1795
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1796
<TT><I>&nbsp;&nbsp;&nbsp;2&nbsp;+&nbsp;(1&nbsp;+&nbsp;1)&nbsp;=&nbsp;4</I></TT><BR>
 
1797
<BR>
 
1798
<TT>Coq&nbsp;&lt;&nbsp;auto&nbsp;with&nbsp;mybase.</TT><BR>
 
1799
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1800
<BR>
 
1801
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1802
<TT><I>auto&nbsp;with&nbsp;mybase.</I></TT><BR>
 
1803
<TT><I>Unnamed_thm7&nbsp;is&nbsp;defined</I></TT><BR>
 
1804
</DIV>
 
1805
<BR>
 
1806
<!--TOC subsubsection My goal is one of the hypotheses, how can I prove it?-->
 
1807
 
 
1808
<H4><A NAME="htoc71">61</A>&nbsp;&nbsp;My goal is one of the hypotheses, how can I prove it?</H4><!--SEC END -->
 
1809
 
 
1810
Use the <TT>assumption</TT> tactic.<BR>
 
1811
<BR>
 
1812
 
 
1813
<DIV ALIGN=left>
 
1814
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;1=1&nbsp;-&gt;&nbsp;1=1.</TT><BR>
 
1815
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1816
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1817
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1818
<TT><I>&nbsp;&nbsp;&nbsp;1&nbsp;=&nbsp;1&nbsp;-&gt;&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1819
<BR>
 
1820
<TT>Coq&nbsp;&lt;&nbsp;intro.</TT><BR>
 
1821
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1822
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1823
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1824
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1825
<TT><I>&nbsp;&nbsp;&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1826
<BR>
 
1827
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
1828
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1829
<BR>
 
1830
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1831
<TT><I>intro.</I></TT><BR>
 
1832
<TT><I>assumption.</I></TT><BR>
 
1833
<TT><I>Unnamed_thm8&nbsp;is&nbsp;defined</I></TT><BR>
 
1834
</DIV>
 
1835
<BR>
 
1836
<!--TOC subsubsection My goal appears twice in the hypotheses and I want to choose which one is used, how can I do it?-->
 
1837
 
 
1838
<H4><A NAME="htoc72">62</A>&nbsp;&nbsp;My goal appears twice in the hypotheses and I want to choose which one is used, how can I do it?</H4><!--SEC END -->
 
1839
 
 
1840
Use the <TT>exact</TT> tactic.
 
1841
 
 
1842
<DIV ALIGN=left>
 
1843
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;1=1&nbsp;-&gt;&nbsp;1=1&nbsp;-&gt;&nbsp;1=1.</TT><BR>
 
1844
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1845
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1846
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1847
<TT><I>&nbsp;&nbsp;&nbsp;1&nbsp;=&nbsp;1&nbsp;-&gt;&nbsp;1&nbsp;=&nbsp;1&nbsp;-&gt;&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1848
<BR>
 
1849
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1850
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1851
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1852
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1853
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1854
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1855
<TT><I>&nbsp;&nbsp;&nbsp;1&nbsp;=&nbsp;1</I></TT><BR>
 
1856
<BR>
 
1857
<TT>Coq&nbsp;&lt;&nbsp;exact&nbsp;H0.</TT><BR>
 
1858
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1859
<BR>
 
1860
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1861
<TT><I>intros.</I></TT><BR>
 
1862
<TT><I>exact&nbsp;H0.</I></TT><BR>
 
1863
<TT><I>Unnamed_thm9&nbsp;is&nbsp;defined</I></TT><BR>
 
1864
</DIV>
 
1865
<BR>
 
1866
<!--TOC subsubsection What can be the difference between applying one hypothesis or another in the context of the last question?-->
 
1867
 
 
1868
<H4><A NAME="htoc73">63</A>&nbsp;&nbsp;What can be the difference between applying one hypothesis or another in the context of the last question?</H4><!--SEC END -->
 
1869
 
 
1870
From a proof point of view it is equivalent but if you want to extract
 
1871
a program from your proof, the two hypotheses can lead to different
 
1872
programs.<BR>
 
1873
<BR>
 
1874
<!--TOC subsubsection My goal is a propositional tautology, how can I prove it?-->
 
1875
 
 
1876
<H4><A NAME="htoc74">64</A>&nbsp;&nbsp;My goal is a propositional tautology, how can I prove it?</H4><!--SEC END -->
 
1877
 
 
1878
Just use the <TT>tauto</TT> tactic.
 
1879
 
 
1880
<DIV ALIGN=left>
 
1881
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B:Prop,&nbsp;A-&gt;&nbsp;(A\/B)&nbsp;/\&nbsp;A.</TT><BR>
 
1882
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1883
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1884
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1885
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;(A&nbsp;\/&nbsp;B)&nbsp;/\&nbsp;A</I></TT><BR>
 
1886
<BR>
 
1887
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1888
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1889
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1890
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
1891
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
1892
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
1893
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1894
<TT><I>&nbsp;&nbsp;&nbsp;(A&nbsp;\/&nbsp;B)&nbsp;/\&nbsp;A</I></TT><BR>
 
1895
<BR>
 
1896
<TT>Coq&nbsp;&lt;&nbsp;tauto.</TT><BR>
 
1897
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1898
<BR>
 
1899
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1900
<TT><I>intros.</I></TT><BR>
 
1901
<TT><I>tauto.</I></TT><BR>
 
1902
<TT><I>Unnamed_thm10&nbsp;is&nbsp;defined</I></TT><BR>
 
1903
</DIV>
 
1904
<BR>
 
1905
<!--TOC subsubsection My goal is a first order formula, how can I prove it?-->
 
1906
 
 
1907
<H4><A NAME="htoc75">65</A>&nbsp;&nbsp;My goal is a first order formula, how can I prove it?</H4><!--SEC END -->
 
1908
 
 
1909
Just use the semi-decision tactic: <TT>firstorder</TT>.<BR>
 
1910
<BR>
 
1911
<!--TOC subsubsection My goal is solvable by a sequence of rewrites, how can I prove it?-->
 
1912
 
 
1913
<H4><A NAME="htoc76">66</A>&nbsp;&nbsp;My goal is solvable by a sequence of rewrites, how can I prove it?</H4><!--SEC END -->
 
1914
 
 
1915
Just use the <TT>congruence</TT> tactic.
 
1916
 
 
1917
<DIV ALIGN=left>
 
1918
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;a&nbsp;b&nbsp;c&nbsp;d&nbsp;e,&nbsp;a=d&nbsp;-&gt;&nbsp;b=e&nbsp;-&gt;&nbsp;c+b=d&nbsp;-&gt;&nbsp;c+e=a.</TT><BR>
 
1919
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1920
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1921
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1922
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;a&nbsp;b&nbsp;c&nbsp;d&nbsp;e&nbsp;:&nbsp;Z,&nbsp;a&nbsp;=&nbsp;d&nbsp;-&gt;&nbsp;b&nbsp;=&nbsp;e&nbsp;-&gt;&nbsp;c&nbsp;+&nbsp;b&nbsp;=&nbsp;d&nbsp;-&gt;&nbsp;c&nbsp;+&nbsp;e&nbsp;=&nbsp;a</I></TT><BR>
 
1923
<BR>
 
1924
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1925
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1926
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1927
<TT><I>&nbsp;&nbsp;a&nbsp;:&nbsp;Z</I></TT><BR>
 
1928
<TT><I>&nbsp;&nbsp;b&nbsp;:&nbsp;Z</I></TT><BR>
 
1929
<TT><I>&nbsp;&nbsp;c&nbsp;:&nbsp;Z</I></TT><BR>
 
1930
<TT><I>&nbsp;&nbsp;d&nbsp;:&nbsp;Z</I></TT><BR>
 
1931
<TT><I>&nbsp;&nbsp;e&nbsp;:&nbsp;Z</I></TT><BR>
 
1932
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;a&nbsp;=&nbsp;d</I></TT><BR>
 
1933
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;b&nbsp;=&nbsp;e</I></TT><BR>
 
1934
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;c&nbsp;+&nbsp;b&nbsp;=&nbsp;d</I></TT><BR>
 
1935
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1936
<TT><I>&nbsp;&nbsp;&nbsp;c&nbsp;+&nbsp;e&nbsp;=&nbsp;a</I></TT><BR>
 
1937
<BR>
 
1938
<TT>Coq&nbsp;&lt;&nbsp;congruence.</TT><BR>
 
1939
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1940
<BR>
 
1941
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1942
<TT><I>intros.</I></TT><BR>
 
1943
<TT><I>congruence.</I></TT><BR>
 
1944
<TT><I>Unnamed_thm11&nbsp;is&nbsp;defined</I></TT><BR>
 
1945
</DIV>
 
1946
<BR>
 
1947
<!--TOC subsubsection My goal is a disequality solvable by a sequence of rewrites, how can I prove it?-->
 
1948
 
 
1949
<H4><A NAME="htoc77">67</A>&nbsp;&nbsp;My goal is a disequality solvable by a sequence of rewrites, how can I prove it?</H4><!--SEC END -->
 
1950
 
 
1951
Just use the <TT>congruence</TT> tactic.<BR>
 
1952
<BR>
 
1953
 
 
1954
<DIV ALIGN=left>
 
1955
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;a&nbsp;b&nbsp;c&nbsp;d,&nbsp;a&lt;&gt;d&nbsp;-&gt;&nbsp;b=a&nbsp;-&gt;&nbsp;d=c+b&nbsp;-&gt;&nbsp;b&lt;&gt;c+b.</TT><BR>
 
1956
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1957
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1958
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1959
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;a&nbsp;b&nbsp;c&nbsp;d&nbsp;:&nbsp;Z,&nbsp;a&nbsp;&lt;&gt;&nbsp;d&nbsp;-&gt;&nbsp;b&nbsp;=&nbsp;a&nbsp;-&gt;&nbsp;d&nbsp;=&nbsp;c&nbsp;+&nbsp;b&nbsp;-&gt;&nbsp;b&nbsp;&lt;&gt;&nbsp;c&nbsp;+&nbsp;b</I></TT><BR>
 
1960
<BR>
 
1961
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
1962
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1963
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
1964
<TT><I>&nbsp;&nbsp;a&nbsp;:&nbsp;Z</I></TT><BR>
 
1965
<TT><I>&nbsp;&nbsp;b&nbsp;:&nbsp;Z</I></TT><BR>
 
1966
<TT><I>&nbsp;&nbsp;c&nbsp;:&nbsp;Z</I></TT><BR>
 
1967
<TT><I>&nbsp;&nbsp;d&nbsp;:&nbsp;Z</I></TT><BR>
 
1968
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;a&nbsp;&lt;&gt;&nbsp;d</I></TT><BR>
 
1969
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;b&nbsp;=&nbsp;a</I></TT><BR>
 
1970
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;d&nbsp;=&nbsp;c&nbsp;+&nbsp;b</I></TT><BR>
 
1971
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
1972
<TT><I>&nbsp;&nbsp;&nbsp;b&nbsp;&lt;&gt;&nbsp;c&nbsp;+&nbsp;b</I></TT><BR>
 
1973
<BR>
 
1974
<TT>Coq&nbsp;&lt;&nbsp;congruence.</TT><BR>
 
1975
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
1976
<BR>
 
1977
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
1978
<TT><I>intros.</I></TT><BR>
 
1979
<TT><I>congruence.</I></TT><BR>
 
1980
<TT><I>Unnamed_thm12&nbsp;is&nbsp;defined</I></TT><BR>
 
1981
</DIV>
 
1982
<BR>
 
1983
<!--TOC subsubsection My goal is an equality on some ring (e.g. natural numbers), how can I prove it?-->
 
1984
 
 
1985
<H4><A NAME="htoc78">68</A>&nbsp;&nbsp;My goal is an equality on some ring (e.g. natural numbers), how can I prove it?</H4><!--SEC END -->
 
1986
 
 
1987
Just use the <TT>ring</TT> tactic.<BR>
 
1988
<BR>
 
1989
 
 
1990
<DIV ALIGN=left>
 
1991
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;ZArith.</TT><BR>
 
1992
<BR>
 
1993
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Ring.</TT><BR>
 
1994
<BR>
 
1995
<TT>Coq&nbsp;&lt;&nbsp;Open&nbsp;Local&nbsp;Scope&nbsp;Z_scope.</TT><BR>
 
1996
<BR>
 
1997
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;a&nbsp;b&nbsp;:&nbsp;Z,&nbsp;(a+b)*(a+b)&nbsp;=&nbsp;a*a&nbsp;+&nbsp;2*a*b&nbsp;+&nbsp;b*b.&nbsp;</TT><BR>
 
1998
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
1999
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2000
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2001
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;a&nbsp;b&nbsp;:&nbsp;Z,&nbsp;(a&nbsp;+&nbsp;b)&nbsp;*&nbsp;(a&nbsp;+&nbsp;b)&nbsp;=&nbsp;a&nbsp;*&nbsp;a&nbsp;+&nbsp;2&nbsp;*&nbsp;a&nbsp;*&nbsp;b&nbsp;+&nbsp;b&nbsp;*&nbsp;b</I></TT><BR>
 
2002
<BR>
 
2003
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2004
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2005
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2006
<TT><I>&nbsp;&nbsp;a&nbsp;:&nbsp;Z</I></TT><BR>
 
2007
<TT><I>&nbsp;&nbsp;b&nbsp;:&nbsp;Z</I></TT><BR>
 
2008
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2009
<TT><I>&nbsp;&nbsp;&nbsp;(a&nbsp;+&nbsp;b)&nbsp;*&nbsp;(a&nbsp;+&nbsp;b)&nbsp;=&nbsp;a&nbsp;*&nbsp;a&nbsp;+&nbsp;2&nbsp;*&nbsp;a&nbsp;*&nbsp;b&nbsp;+&nbsp;b&nbsp;*&nbsp;b</I></TT><BR>
 
2010
<BR>
 
2011
<TT>Coq&nbsp;&lt;&nbsp;ring.</TT><BR>
 
2012
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2013
<BR>
 
2014
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2015
<TT><I>intros.</I></TT><BR>
 
2016
<TT><I>ring.</I></TT><BR>
 
2017
<TT><I>Unnamed_thm13&nbsp;is&nbsp;defined</I></TT><BR>
 
2018
</DIV>
 
2019
<BR>
 
2020
<!--TOC subsubsection My goal is an equality on some field (e.g. real numbers), how can I prove it?-->
 
2021
 
 
2022
<H4><A NAME="htoc79">69</A>&nbsp;&nbsp;My goal is an equality on some field (e.g. real numbers), how can I prove it?</H4><!--SEC END -->
 
2023
 
 
2024
Just use the <TT>field</TT> tactic.<BR>
 
2025
<BR>
 
2026
 
 
2027
<DIV ALIGN=left>
 
2028
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;Reals.</TT><BR>
 
2029
<BR>
 
2030
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Ring.</TT><BR>
 
2031
<BR>
 
2032
<TT>Coq&nbsp;&lt;&nbsp;Open&nbsp;Local&nbsp;Scope&nbsp;R_scope.</TT><BR>
 
2033
<BR>
 
2034
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;a&nbsp;b&nbsp;:&nbsp;R,&nbsp;b*a&lt;&gt;0&nbsp;-&gt;&nbsp;(a/b)&nbsp;*&nbsp;(b/a)&nbsp;=&nbsp;1.&nbsp;</TT><BR>
 
2035
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2036
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2037
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2038
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;a&nbsp;b&nbsp;:&nbsp;R,&nbsp;b&nbsp;*&nbsp;a&nbsp;&lt;&gt;&nbsp;0&nbsp;-&gt;&nbsp;a&nbsp;/&nbsp;b&nbsp;*&nbsp;(b&nbsp;/&nbsp;a)&nbsp;=&nbsp;1</I></TT><BR>
 
2039
<BR>
 
2040
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2041
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2042
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2043
<TT><I>&nbsp;&nbsp;a&nbsp;:&nbsp;R</I></TT><BR>
 
2044
<TT><I>&nbsp;&nbsp;b&nbsp;:&nbsp;R</I></TT><BR>
 
2045
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;b&nbsp;*&nbsp;a&nbsp;&lt;&gt;&nbsp;0</I></TT><BR>
 
2046
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2047
<TT><I>&nbsp;&nbsp;&nbsp;a&nbsp;/&nbsp;b&nbsp;*&nbsp;(b&nbsp;/&nbsp;a)&nbsp;=&nbsp;1</I></TT><BR>
 
2048
<BR>
 
2049
<TT>Coq&nbsp;&lt;&nbsp;field.</TT><BR>
 
2050
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2051
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2052
<TT><I>&nbsp;&nbsp;a&nbsp;:&nbsp;R</I></TT><BR>
 
2053
<TT><I>&nbsp;&nbsp;b&nbsp;:&nbsp;R</I></TT><BR>
 
2054
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;b&nbsp;*&nbsp;a&nbsp;&lt;&gt;&nbsp;0</I></TT><BR>
 
2055
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2056
<TT><I>&nbsp;&nbsp;&nbsp;b&nbsp;*&nbsp;a&nbsp;&lt;&gt;&nbsp;0</I></TT><BR>
 
2057
<BR>
 
2058
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
2059
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2060
<BR>
 
2061
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2062
<TT><I>intros.</I></TT><BR>
 
2063
<TT><I>field.</I></TT><BR>
 
2064
<TT><I>assumption.</I></TT><BR>
 
2065
<TT><I>Unnamed_thm14&nbsp;is&nbsp;defined</I></TT><BR>
 
2066
</DIV>
 
2067
<BR>
 
2068
<!--TOC subsubsection My goal is an inequality on integers in Presburger's arithmetic (an expression build from +,-,constants and variables), how can I prove it?-->
 
2069
 
 
2070
<H4><A NAME="htoc80">70</A>&nbsp;&nbsp;My goal is an inequality on integers in Presburger's arithmetic (an expression build from +,-,constants and variables), how can I prove it?</H4><!--SEC END -->
 
2071
 
 
2072
 
 
2073
<DIV ALIGN=left>
 
2074
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;ZArith.</TT><BR>
 
2075
<BR>
 
2076
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Omega.</TT><BR>
 
2077
<BR>
 
2078
<TT>Coq&nbsp;&lt;&nbsp;Open&nbsp;Local&nbsp;Scope&nbsp;Z_scope.</TT><BR>
 
2079
<BR>
 
2080
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;a&nbsp;:&nbsp;Z,&nbsp;a&gt;0&nbsp;-&gt;&nbsp;a+a&nbsp;&gt;&nbsp;a.&nbsp;</TT><BR>
 
2081
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2082
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2083
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2084
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;a&nbsp;:&nbsp;Z,&nbsp;a&nbsp;&gt;&nbsp;0&nbsp;-&gt;&nbsp;a&nbsp;+&nbsp;a&nbsp;&gt;&nbsp;a</I></TT><BR>
 
2085
<BR>
 
2086
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2087
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2088
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2089
<TT><I>&nbsp;&nbsp;a&nbsp;:&nbsp;Z</I></TT><BR>
 
2090
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;a&nbsp;&gt;&nbsp;0</I></TT><BR>
 
2091
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2092
<TT><I>&nbsp;&nbsp;&nbsp;a&nbsp;+&nbsp;a&nbsp;&gt;&nbsp;a</I></TT><BR>
 
2093
<BR>
 
2094
<TT>Coq&nbsp;&lt;&nbsp;omega.</TT><BR>
 
2095
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2096
<BR>
 
2097
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2098
<TT><I>intros.</I></TT><BR>
 
2099
<TT><I>omega.</I></TT><BR>
 
2100
<TT><I>Unnamed_thm15&nbsp;is&nbsp;defined</I></TT><BR>
 
2101
</DIV>
 
2102
<BR>
 
2103
<!--TOC subsubsection My goal is an equation solvable using equational hypothesis on some ring (e.g. natural numbers), how can I prove it?-->
 
2104
 
 
2105
<H4><A NAME="htoc81">71</A>&nbsp;&nbsp;My goal is an equation solvable using equational hypothesis on some ring (e.g. natural numbers), how can I prove it?</H4><!--SEC END -->
 
2106
 
 
2107
You need the <TT>gb</TT> tactic (see Lo�c Pottier's homepage).<BR>
 
2108
<BR>
 
2109
<!--TOC subsection Tactics usage-->
 
2110
 
 
2111
<H3><A NAME="htoc82">6.2</A>&nbsp;&nbsp;Tactics usage</H3><!--SEC END -->
 
2112
 
 
2113
<!--TOC subsubsection I want to state a fact that I will use later as an hypothesis, how can I do it?-->
 
2114
 
 
2115
<H4><A NAME="htoc83">72</A>&nbsp;&nbsp;I want to state a fact that I will use later as an hypothesis, how can I do it?</H4><!--SEC END -->
 
2116
 
 
2117
If you want to use forward reasoning (first proving the fact and then
 
2118
using it) you just need to use the <TT>assert</TT> tactic. If you want to use
 
2119
backward reasoning (proving your goal using an assumption and then
 
2120
proving the assumption) use the <TT>cut</TT> tactic.<BR>
 
2121
<BR>
 
2122
 
 
2123
<DIV ALIGN=left>
 
2124
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;D&nbsp;:&nbsp;Prop,&nbsp;(A&nbsp;-&gt;&nbsp;B)&nbsp;-&gt;&nbsp;(B-&gt;C)&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;C.&nbsp;</TT><BR>
 
2125
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2126
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2127
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2128
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;:&nbsp;Prop,&nbsp;Prop&nbsp;-&gt;&nbsp;(A&nbsp;-&gt;&nbsp;B)&nbsp;-&gt;&nbsp;(B&nbsp;-&gt;&nbsp;C)&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2129
<BR>
 
2130
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2131
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2132
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2133
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2134
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2135
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2136
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2137
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2138
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2139
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2140
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2141
<TT><I>&nbsp;&nbsp;&nbsp;C</I></TT><BR>
 
2142
<BR>
 
2143
<TT>Coq&nbsp;&lt;&nbsp;assert&nbsp;(A-&gt;C).</TT><BR>
 
2144
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
2145
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2146
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2147
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2148
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2149
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2150
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2151
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2152
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2153
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2154
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2155
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
2156
<TT><I>&nbsp;C</I></TT><BR>
 
2157
<BR>
 
2158
<TT>Coq&nbsp;&lt;&nbsp;intro;apply&nbsp;H0;apply&nbsp;H;assumption.</TT><BR>
 
2159
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2160
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2161
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2162
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2163
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2164
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2165
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2166
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2167
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2168
<TT><I>&nbsp;&nbsp;H2&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2169
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2170
<TT><I>&nbsp;&nbsp;&nbsp;C</I></TT><BR>
 
2171
<BR>
 
2172
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;H2.</TT><BR>
 
2173
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2174
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2175
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2176
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2177
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2178
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2179
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2180
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2181
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2182
<TT><I>&nbsp;&nbsp;H2&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2183
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2184
<TT><I>&nbsp;&nbsp;&nbsp;A</I></TT><BR>
 
2185
<BR>
 
2186
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
2187
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2188
<BR>
 
2189
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2190
<TT><I>intros.</I></TT><BR>
 
2191
<TT><I>assert&nbsp;(A&nbsp;-&gt;&nbsp;C).</I></TT><BR>
 
2192
<TT><I>&nbsp;intro;&nbsp;apply&nbsp;H0;&nbsp;apply&nbsp;H;&nbsp;assumption.</I></TT><BR>
 
2193
<TT><I>&nbsp;apply&nbsp;H2.</I></TT><BR>
 
2194
<TT><I>&nbsp;&nbsp;&nbsp;assumption.</I></TT><BR>
 
2195
<TT><I>Unnamed_thm16&nbsp;is&nbsp;defined</I></TT><BR>
 
2196
<BR>
 
2197
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
2198
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;D&nbsp;:&nbsp;Prop,&nbsp;(A&nbsp;-&gt;&nbsp;B)&nbsp;-&gt;&nbsp;(B-&gt;C)&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;C.&nbsp;</TT><BR>
 
2199
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2200
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2201
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2202
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;:&nbsp;Prop,&nbsp;Prop&nbsp;-&gt;&nbsp;(A&nbsp;-&gt;&nbsp;B)&nbsp;-&gt;&nbsp;(B&nbsp;-&gt;&nbsp;C)&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2203
<BR>
 
2204
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2205
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2206
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2207
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2208
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2209
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2210
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2211
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2212
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2213
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2214
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2215
<TT><I>&nbsp;&nbsp;&nbsp;C</I></TT><BR>
 
2216
<BR>
 
2217
<TT>Coq&nbsp;&lt;&nbsp;cut&nbsp;(A-&gt;C).</TT><BR>
 
2218
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
2219
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2220
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2221
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2222
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2223
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2224
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2225
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2226
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2227
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2228
<TT><I>&nbsp;&nbsp;&nbsp;(A&nbsp;-&gt;&nbsp;C)&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2229
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
2230
<TT><I>&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2231
<BR>
 
2232
<TT>Coq&nbsp;&lt;&nbsp;intro.</TT><BR>
 
2233
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
2234
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2235
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2236
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2237
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2238
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2239
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2240
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2241
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2242
<TT><I>&nbsp;&nbsp;H2&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2243
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2244
<TT><I>&nbsp;&nbsp;&nbsp;C</I></TT><BR>
 
2245
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
2246
<TT><I>&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2247
<BR>
 
2248
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;H2;assumption.</TT><BR>
 
2249
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2250
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2251
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2252
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2253
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2254
<TT><I>&nbsp;&nbsp;D&nbsp;:&nbsp;Prop</I></TT><BR>
 
2255
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;B</I></TT><BR>
 
2256
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2257
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2258
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2259
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;-&gt;&nbsp;C</I></TT><BR>
 
2260
<BR>
 
2261
<TT>Coq&nbsp;&lt;&nbsp;intro;apply&nbsp;H0;apply&nbsp;H;assumption.</TT><BR>
 
2262
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2263
<BR>
 
2264
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2265
<TT><I>intros.</I></TT><BR>
 
2266
<TT><I>cut&nbsp;(A&nbsp;-&gt;&nbsp;C).</I></TT><BR>
 
2267
<TT><I>&nbsp;intro.</I></TT><BR>
 
2268
<TT><I>&nbsp;&nbsp;&nbsp;apply&nbsp;H2;&nbsp;assumption.</I></TT><BR>
 
2269
<TT><I>&nbsp;intro;&nbsp;apply&nbsp;H0;&nbsp;apply&nbsp;H;&nbsp;assumption.</I></TT><BR>
 
2270
<TT><I>Unnamed_thm17&nbsp;is&nbsp;defined</I></TT><BR>
 
2271
</DIV>
 
2272
<BR>
 
2273
<!--TOC subsubsection I want to state a fact that I will use later as an hypothesis and prove it later, how can I do it?-->
 
2274
 
 
2275
<H4><A NAME="htoc84">73</A>&nbsp;&nbsp;I want to state a fact that I will use later as an hypothesis and prove it later, how can I do it?</H4><!--SEC END -->
 
2276
 
 
2277
You can use <TT>cut</TT> followed by <TT>intro</TT> or you can use the following <FONT COLOR=navy>Ltac</FONT> command:
 
2278
<PRE>
 
2279
Ltac assert_later t := cut t;[intro|idtac]. 
 
2280
</PRE>
 
2281
<!--TOC subsubsection What is the difference between <TT>Qed</TT> and <TT>Defined</TT>?-->
 
2282
 
 
2283
<H4><A NAME="htoc85">74</A>&nbsp;&nbsp;What is the difference between <TT>Qed</TT> and <TT>Defined</TT>?</H4><!--SEC END -->
 
2284
 
 
2285
These two commands perform type checking, but when <TT>Defined</TT> is used the new definition is set as transparent, otherwise it is defined as opaque (see <A HREF="#opaque">167</A>).<BR>
 
2286
<BR>
 
2287
<!--TOC subsubsection How can I know what a tactic does?-->
 
2288
 
 
2289
<H4><A NAME="htoc86">75</A>&nbsp;&nbsp;How can I know what a tactic does?</H4><!--SEC END -->
 
2290
 
 
2291
You can use the <TT>info</TT> command.<BR>
 
2292
<BR>
 
2293
<!--TOC subsubsection Why <TT>auto</TT> does not work? How can I fix it?-->
 
2294
 
 
2295
<H4><A NAME="htoc87">76</A>&nbsp;&nbsp;Why <TT>auto</TT> does not work? How can I fix it?</H4><!--SEC END -->
 
2296
 
 
2297
You can increase the depth of the proof search or add some lemmas in the base of hints.
 
2298
Perhaps you may need to use <TT>eauto</TT>.<BR>
 
2299
<BR>
 
2300
<!--TOC subsubsection What is <TT>eauto</TT>?-->
 
2301
 
 
2302
<H4><A NAME="htoc88">77</A>&nbsp;&nbsp;What is <TT>eauto</TT>?</H4><!--SEC END -->
 
2303
 
 
2304
This is the same tactic as <TT>auto</TT>, but it relies on <TT>eapply</TT> instead of <TT>apply</TT>.<BR>
 
2305
<BR>
 
2306
<!--TOC subsubsection How can I speed up <TT>auto</TT>?-->
 
2307
 
 
2308
<H4><A NAME="htoc89">78</A>&nbsp;&nbsp;How can I speed up <TT>auto</TT>?</H4><!--SEC END -->
 
2309
 
 
2310
You can use <TT>info </TT><TT>auto</TT>to replace <TT>auto</TT> by the tactics it generates.
 
2311
You can split your hint bases into smaller ones.<BR>
 
2312
<BR>
 
2313
<!--TOC subsubsection What is the equivalent of <TT>tauto</TT> for classical logic?-->
 
2314
 
 
2315
<H4><A NAME="htoc90">79</A>&nbsp;&nbsp;What is the equivalent of <TT>tauto</TT> for classical logic?</H4><!--SEC END -->
 
2316
 
 
2317
Currently there are no equivalent tactic for classical logic. You can use G�del's ``not not'' translation.<BR>
 
2318
<BR>
 
2319
<!--TOC subsubsection I want to replace some term with another in the goal, how can I do it?-->
 
2320
 
 
2321
<H4><A NAME="htoc91">80</A>&nbsp;&nbsp;I want to replace some term with another in the goal, how can I do it?</H4><!--SEC END -->
 
2322
 
 
2323
If one of your hypothesis (say <TT>H</TT>) states that the terms are equal you can use the <TT>rewrite</TT> tactic. Otherwise you can use the <TT>replace</TT> <TT>with</TT> tactic. <BR>
 
2324
<BR>
 
2325
<!--TOC subsubsection I want to replace some term with another in an hypothesis, how can I do it?-->
 
2326
 
 
2327
<H4><A NAME="htoc92">81</A>&nbsp;&nbsp;I want to replace some term with another in an hypothesis, how can I do it?</H4><!--SEC END -->
 
2328
 
 
2329
You can use the <TT>rewrite</TT> <TT>in</TT> tactic.<BR>
 
2330
<BR>
 
2331
<!--TOC subsubsection I want to replace some symbol with its definition, how can I do it?-->
 
2332
 
 
2333
<H4><A NAME="htoc93">82</A>&nbsp;&nbsp;I want to replace some symbol with its definition, how can I do it?</H4><!--SEC END -->
 
2334
 
 
2335
You can use the <TT>unfold</TT> tactic.<BR>
 
2336
<BR>
 
2337
<!--TOC subsubsection How can I reduce some term?-->
 
2338
 
 
2339
<H4><A NAME="htoc94">83</A>&nbsp;&nbsp;How can I reduce some term?</H4><!--SEC END -->
 
2340
 
 
2341
You can use the <TT>simpl</TT> tactic.<BR>
 
2342
<BR>
 
2343
<!--TOC subsubsection How can I declare a shortcut for some term?-->
 
2344
 
 
2345
<H4><A NAME="htoc95">84</A>&nbsp;&nbsp;How can I declare a shortcut for some term?</H4><!--SEC END -->
 
2346
 
 
2347
You can use the <TT>set</TT> or <TT>pose</TT> tactics.<BR>
 
2348
<BR>
 
2349
<!--TOC subsubsection How can I perform case analysis?-->
 
2350
 
 
2351
<H4><A NAME="htoc96">85</A>&nbsp;&nbsp;How can I perform case analysis?</H4><!--SEC END -->
 
2352
 
 
2353
You can use the <TT>case</TT> or <TT>destruct</TT> tactics.<BR>
 
2354
<BR>
 
2355
<!--TOC subsubsection Why should I name my intros?-->
 
2356
 
 
2357
<H4><A NAME="htoc97">86</A>&nbsp;&nbsp;Why should I name my intros?</H4><!--SEC END -->
 
2358
 
 
2359
When you use the <TT>intro</TT> tactic you don't have to give a name to your
 
2360
hypothesis. If you do so the name will be generated by <FONT COLOR=navy>Coq</FONT> but your
 
2361
scripts may be less robust. If you add some hypothesis to your theorem
 
2362
(or change their order), you will have to change your proof to adapt
 
2363
to the new names.<BR>
 
2364
<BR>
 
2365
<!--TOC subsubsection How can I automatize the naming?-->
 
2366
 
 
2367
<H4><A NAME="htoc98">87</A>&nbsp;&nbsp;How can I automatize the naming?</H4><!--SEC END -->
 
2368
 
 
2369
You can use the <TT>Show Intro.</TT> or <TT>Show Intros.</TT> commands to generate the names and use your editor to generate a fully named <TT>intro</TT> tactic. 
 
2370
This can be automatized within <TT>xemacs</TT>.<BR>
 
2371
<BR>
 
2372
 
 
2373
<DIV ALIGN=left>
 
2374
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;B&nbsp;-&gt;&nbsp;C&nbsp;-&gt;&nbsp;A/\B/\C.</TT><BR>
 
2375
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2376
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2377
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2378
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;B&nbsp;-&gt;&nbsp;C&nbsp;-&gt;&nbsp;A&nbsp;/\&nbsp;B&nbsp;/\&nbsp;C</I></TT><BR>
 
2379
<BR>
 
2380
<TT>Coq&nbsp;&lt;&nbsp;Show&nbsp;Intros.</TT><BR>
 
2381
<TT><I>A&nbsp;B&nbsp;C&nbsp;H&nbsp;H0</I></TT><BR>
 
2382
<TT><I>H1</I></TT><BR>
 
2383
<BR>
 
2384
<TT>Coq&nbsp;&lt;&nbsp;(*</TT><BR>
 
2385
<TT>Coq&nbsp;&lt;&nbsp;A&nbsp;B&nbsp;C&nbsp;H&nbsp;H0</TT><BR>
 
2386
<TT>Coq&nbsp;&lt;&nbsp;H1</TT><BR>
 
2387
<TT>Coq&nbsp;&lt;&nbsp;*)</TT><BR>
 
2388
<TT>Coq&nbsp;&lt;&nbsp;intros&nbsp;A&nbsp;B&nbsp;C&nbsp;H&nbsp;H0&nbsp;H1.</TT><BR>
 
2389
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2390
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2391
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2392
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2393
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2394
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
2395
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
2396
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;C</I></TT><BR>
 
2397
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2398
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;/\&nbsp;B&nbsp;/\&nbsp;C</I></TT><BR>
 
2399
<BR>
 
2400
<TT>Coq&nbsp;&lt;&nbsp;repeat&nbsp;split;assumption.</TT><BR>
 
2401
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2402
<BR>
 
2403
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2404
<TT><I>intros&nbsp;A&nbsp;B&nbsp;C&nbsp;H&nbsp;H0&nbsp;H1.</I></TT><BR>
 
2405
<TT><I>repeat&nbsp;split;&nbsp;assumption.</I></TT><BR>
 
2406
<TT><I>Unnamed_thm18&nbsp;is&nbsp;defined</I></TT><BR>
 
2407
</DIV>
 
2408
<BR>
 
2409
<!--TOC subsubsection I want to automatize the use of some tactic, how can I do it?-->
 
2410
 
 
2411
<H4><A NAME="htoc99">88</A>&nbsp;&nbsp;I want to automatize the use of some tactic, how can I do it?</H4><!--SEC END -->
 
2412
 
 
2413
You need to use the <TT>proof with T</TT> command and add ... at the
 
2414
end of your sentences.<BR>
 
2415
<BR>
 
2416
For instance:
 
2417
 
 
2418
<DIV ALIGN=left>
 
2419
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;B/\C&nbsp;-&gt;&nbsp;A/\B/\C.</TT><BR>
 
2420
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2421
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2422
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2423
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;C&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;B&nbsp;/\&nbsp;C&nbsp;-&gt;&nbsp;A&nbsp;/\&nbsp;B&nbsp;/\&nbsp;C</I></TT><BR>
 
2424
<BR>
 
2425
<TT>Coq&nbsp;&lt;&nbsp;Proof&nbsp;with&nbsp;assumption.</TT><BR>
 
2426
<BR>
 
2427
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2428
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2429
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2430
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2431
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2432
<TT><I>&nbsp;&nbsp;C&nbsp;:&nbsp;Prop</I></TT><BR>
 
2433
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
2434
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B&nbsp;/\&nbsp;C</I></TT><BR>
 
2435
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2436
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;/\&nbsp;B&nbsp;/\&nbsp;C</I></TT><BR>
 
2437
<BR>
 
2438
<TT>Coq&nbsp;&lt;&nbsp;split...</TT><BR>
 
2439
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2440
<BR>
 
2441
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2442
<TT><I>intros.</I></TT><BR>
 
2443
<TT><I>split.</I></TT><BR>
 
2444
<TT><I>Unnamed_thm19&nbsp;is&nbsp;defined</I></TT><BR>
 
2445
</DIV>
 
2446
<BR>
 
2447
<!--TOC subsubsection I want to execute the <TT>p</TT>roof with tactic only if it solves the goal, how can I do it?-->
 
2448
 
 
2449
<H4><A NAME="htoc100">89</A>&nbsp;&nbsp;I want to execute the <TT>p</TT>roof with tactic only if it solves the goal, how can I do it?</H4><!--SEC END -->
 
2450
 
 
2451
You need to use the <TT>try</TT> and <TT>solve</TT> tactics. For instance:
 
2452
 
 
2453
<DIV ALIGN=left>
 
2454
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;ZArith.</TT><BR>
 
2455
<BR>
 
2456
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Ring.</TT><BR>
 
2457
<BR>
 
2458
<TT>Coq&nbsp;&lt;&nbsp;Open&nbsp;Local&nbsp;Scope&nbsp;Z_scope.</TT><BR>
 
2459
<BR>
 
2460
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;a&nbsp;b&nbsp;c&nbsp;:&nbsp;Z,&nbsp;a+b=b+a.</TT><BR>
 
2461
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2462
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2463
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2464
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;a&nbsp;b&nbsp;:&nbsp;Z,&nbsp;Z&nbsp;-&gt;&nbsp;a&nbsp;+&nbsp;b&nbsp;=&nbsp;b&nbsp;+&nbsp;a</I></TT><BR>
 
2465
<BR>
 
2466
<TT>Coq&nbsp;&lt;&nbsp;Proof&nbsp;with&nbsp;try&nbsp;solve&nbsp;[ring].</TT><BR>
 
2467
<BR>
 
2468
<TT>Coq&nbsp;&lt;&nbsp;intros...</TT><BR>
 
2469
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2470
<BR>
 
2471
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2472
<TT><I>intros.</I></TT><BR>
 
2473
<TT><I>Unnamed_thm20&nbsp;is&nbsp;defined</I></TT><BR>
 
2474
</DIV>
 
2475
<BR>
 
2476
<!--TOC subsubsection How can I do the opposite of the <TT>intro</TT> tactic?-->
 
2477
 
 
2478
<H4><A NAME="htoc101">90</A>&nbsp;&nbsp;How can I do the opposite of the <TT>intro</TT> tactic?</H4><!--SEC END -->
 
2479
 
 
2480
You can use the <TT>generalize</TT> tactic.<BR>
 
2481
<BR>
 
2482
 
 
2483
<DIV ALIGN=left>
 
2484
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;A-&gt;B-&gt;&nbsp;A/\B.</TT><BR>
 
2485
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2486
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2487
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2488
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;A&nbsp;B&nbsp;:&nbsp;Prop,&nbsp;A&nbsp;-&gt;&nbsp;B&nbsp;-&gt;&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
2489
<BR>
 
2490
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
2491
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2492
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2493
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2494
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2495
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
2496
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
2497
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2498
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
2499
<BR>
 
2500
<TT>Coq&nbsp;&lt;&nbsp;generalize&nbsp;H.</TT><BR>
 
2501
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2502
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2503
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2504
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2505
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
2506
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
2507
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2508
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;-&gt;&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
2509
<BR>
 
2510
<TT>Coq&nbsp;&lt;&nbsp;intro.</TT><BR>
 
2511
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2512
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2513
<TT><I>&nbsp;&nbsp;A&nbsp;:&nbsp;Prop</I></TT><BR>
 
2514
<TT><I>&nbsp;&nbsp;B&nbsp;:&nbsp;Prop</I></TT><BR>
 
2515
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;A</I></TT><BR>
 
2516
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;B</I></TT><BR>
 
2517
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;A</I></TT><BR>
 
2518
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2519
<TT><I>&nbsp;&nbsp;&nbsp;A&nbsp;/\&nbsp;B</I></TT><BR>
 
2520
<BR>
 
2521
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
2522
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2523
<BR>
 
2524
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2525
<TT><I>intros.</I></TT><BR>
 
2526
<TT><I>generalize&nbsp;H.</I></TT><BR>
 
2527
<TT><I>intro.</I></TT><BR>
 
2528
<TT><I>auto.</I></TT><BR>
 
2529
<TT><I>Unnamed_thm21&nbsp;is&nbsp;defined</I></TT><BR>
 
2530
</DIV>
 
2531
<BR>
 
2532
<!--TOC subsubsection One of the hypothesis is an equality between a variable and some term, I want to get rid of this variable, how can I do it?-->
 
2533
 
 
2534
<H4><A NAME="htoc102">91</A>&nbsp;&nbsp;One of the hypothesis is an equality between a variable and some term, I want to get rid of this variable, how can I do it?</H4><!--SEC END -->
 
2535
 
 
2536
You can use the <TT>subst</TT> tactic. This will rewrite the equality everywhere and clear the assumption.<BR>
 
2537
<BR>
 
2538
<!--TOC subsubsection What can I do if I get ``<TT>generated subgoal term has metavariables in it </TT>''?-->
 
2539
 
 
2540
<H4><A NAME="htoc103">92</A>&nbsp;&nbsp;What can I do if I get ``<TT>generated subgoal term has metavariables in it </TT>''?</H4><!--SEC END -->
 
2541
 
 
2542
You should use the <TT>eapply</TT> tactic, this will generate some goals containing metavariables. <BR>
 
2543
<BR>
 
2544
<!--TOC subsubsection How can I instantiate some metavariable?-->
 
2545
 
 
2546
<H4><A NAME="htoc104">93</A>&nbsp;&nbsp;How can I instantiate some metavariable?</H4><!--SEC END -->
 
2547
 
 
2548
Just use the <TT>instantiate</TT> tactic.<BR>
 
2549
<BR>
 
2550
<!--TOC subsubsection What is the use of the <TT>pattern</TT> tactic?-->
 
2551
 
 
2552
<H4><A NAME="htoc105">94</A>&nbsp;&nbsp;What is the use of the <TT>pattern</TT> tactic?</H4><!--SEC END -->
 
2553
 
 
2554
The <TT>pattern</TT> tactic transforms the current goal, performing
 
2555
beta-expansion on all the applications featuring this tactic's
 
2556
argument. For instance, if the current goal includes a subterm <TT>phi(t)</TT>, then <TT>pattern t</TT> transforms the subterm into <TT>(fun
 
2557
x:A =&gt; phi(x)) t</TT>. This can be useful when <TT>apply</TT> fails on matching,
 
2558
to abstract the appropriate terms.<BR>
 
2559
<BR>
 
2560
<!--TOC subsubsection What is the difference between assert, cut and generalize?-->
 
2561
 
 
2562
<H4><A NAME="htoc106">95</A>&nbsp;&nbsp;What is the difference between assert, cut and generalize?</H4><!--SEC END -->
 
2563
 
 
2564
PS: Notice for people that are interested in proof rendering that <TT>assert</TT>and <TT>pose</TT> (and <TT>cut</TT>) are not rendered the same as <TT>generalize</TT> (see the
 
2565
HELM experimental rendering tool at <A HREF="http://helm.cs.unibo.it/library.html"><TT>http://helm.cs.unibo.it</TT></A>, link
 
2566
HELM, link COQ Online). Indeed <TT>generalize</TT> builds a beta-expanded term
 
2567
while <TT>assert</TT>, <TT>pose</TT> and <TT>cut</TT> uses a let-in.
 
2568
<PRE>
 
2569
  (* Goal is T *)
 
2570
  generalize (H1 H2).
 
2571
  (* Goal is A-&gt;T *)
 
2572
  ... a proof of A-&gt;T ...
 
2573
</PRE>
 
2574
is rendered into something like
 
2575
<PRE>
 
2576
  (h) ... the proof of A-&gt;T ...
 
2577
      we proved A-&gt;T
 
2578
  (h0) by (H1 H2) we proved A
 
2579
  by (h h0) we proved T
 
2580
</PRE>while 
 
2581
<PRE>
 
2582
  (* Goal is T *)
 
2583
  assert q := (H1 H2).
 
2584
  (* Goal is A *)
 
2585
  ... a proof of A ...
 
2586
  (* Goal is A |- T *)
 
2587
  ... a proof of T ...
 
2588
</PRE>is rendered into something like
 
2589
<PRE>
 
2590
  (q) ... the proof of A ...
 
2591
      we proved A
 
2592
  ... the proof of T ...
 
2593
  we proved T
 
2594
</PRE>Otherwise said, <TT>generalize</TT> is not rendered in a forward-reasoning way,
 
2595
while <TT>assert</TT> is.<BR>
 
2596
<BR>
 
2597
<!--TOC subsubsection What can I do if <FONT COLOR=navy>Coq</FONT>can not infer some implicit argument ?-->
 
2598
 
 
2599
<H4><A NAME="htoc107">96</A>&nbsp;&nbsp;What can I do if <FONT COLOR=navy>Coq</FONT>can not infer some implicit argument ?</H4><!--SEC END -->
 
2600
 
 
2601
You can state explicitely what this implicit argument is. See <A HREF="#implicit">97</A>.<BR>
 
2602
<BR>
 
2603
<!--TOC subsubsection How can I explicit some implicit argument ?-->
 
2604
 
 
2605
<H4><A NAME="htoc108">97</A>&nbsp;&nbsp;How can I explicit some implicit argument ?</H4><!--SEC END -->
 
2606
<A NAME="implicit"></A>
 
2607
Just use <TT>A:=term</TT> where <TT>A</TT> is the argument.<BR>
 
2608
<BR>
 
2609
For instance if you want to use the existence of ``nil'' on nat*nat lists:
 
2610
<PRE>
 
2611
exists (nil (A:=(nat*nat))).
 
2612
</PRE>
 
2613
<!--TOC subsection Proof management-->
 
2614
 
 
2615
<H3><A NAME="htoc109">6.3</A>&nbsp;&nbsp;Proof management</H3><!--SEC END -->
 
2616
 
 
2617
<!--TOC subsubsection How can I change the order of the subgoals?-->
 
2618
 
 
2619
<H4><A NAME="htoc110">98</A>&nbsp;&nbsp;How can I change the order of the subgoals?</H4><!--SEC END -->
 
2620
 
 
2621
You can use the <TT>Focus</TT> command to concentrate on some goal. When the goal is proved you will see the remaining goals.<BR>
 
2622
<BR>
 
2623
<!--TOC subsubsection How can I change the order of the hypothesis?-->
 
2624
 
 
2625
<H4><A NAME="htoc111">99</A>&nbsp;&nbsp;How can I change the order of the hypothesis?</H4><!--SEC END -->
 
2626
 
 
2627
You can use the <TT>Move ... after</TT> command.<BR>
 
2628
<BR>
 
2629
<!--TOC subsubsection How can I change the name of an hypothesis?-->
 
2630
 
 
2631
<H4><A NAME="htoc112">100</A>&nbsp;&nbsp;How can I change the name of an hypothesis?</H4><!--SEC END -->
 
2632
 
 
2633
You can use the <TT>Rename ... into</TT> command.<BR>
 
2634
<BR>
 
2635
<!--TOC subsubsection How can I delete some hypothesis?-->
 
2636
 
 
2637
<H4><A NAME="htoc113">101</A>&nbsp;&nbsp;How can I delete some hypothesis?</H4><!--SEC END -->
 
2638
 
 
2639
You can use the <TT>Clear</TT> command.<BR>
 
2640
<BR>
 
2641
<!--TOC subsubsection How can use a proof which is not finished?-->
 
2642
 
 
2643
<H4><A NAME="htoc114">102</A>&nbsp;&nbsp;How can use a proof which is not finished?</H4><!--SEC END -->
 
2644
 
 
2645
You can use the <TT>Admitted</TT> command to state your current proof as an axiom.<BR>
 
2646
<BR>
 
2647
<!--TOC subsubsection How can I state a conjecture?-->
 
2648
 
 
2649
<H4><A NAME="htoc115">103</A>&nbsp;&nbsp;How can I state a conjecture?</H4><!--SEC END -->
 
2650
 
 
2651
You can use the <TT>Admitted</TT> command to state your current proof as an axiom.<BR>
 
2652
<BR>
 
2653
<!--TOC subsubsection What is the difference between a lemma, a fact and a theorem?-->
 
2654
 
 
2655
<H4><A NAME="htoc116">104</A>&nbsp;&nbsp;What is the difference between a lemma, a fact and a theorem?</H4><!--SEC END -->
 
2656
 
 
2657
From <FONT COLOR=navy>Coq</FONT> point of view there are no difference. But some tools can
 
2658
have a different behavior when you use a lemma rather than a
 
2659
theorem. For instance <TT>coqdoc</TT> will not generate documentation for
 
2660
the lemmas within your development.<BR>
 
2661
<BR>
 
2662
<!--TOC subsubsection How can I organize my proofs?-->
 
2663
 
 
2664
<H4><A NAME="htoc117">105</A>&nbsp;&nbsp;How can I organize my proofs?</H4><!--SEC END -->
 
2665
 
 
2666
You can organize your proofs using the section mechanism of <FONT COLOR=navy>Coq</FONT>. Have
 
2667
a look at the manual for further information.<BR>
 
2668
<BR>
 
2669
<!--TOC section Inductive and Co-inductive types-->
 
2670
 
 
2671
<H2><A NAME="htoc118">7</A>&nbsp;&nbsp;Inductive and Co-inductive types</H2><!--SEC END -->
 
2672
 
 
2673
<!--TOC subsection General-->
 
2674
 
 
2675
<H3><A NAME="htoc119">7.1</A>&nbsp;&nbsp;General</H3><!--SEC END -->
 
2676
 
 
2677
<!--TOC subsubsection How can I prove that two constructors are different?-->
 
2678
 
 
2679
<H4><A NAME="htoc120">106</A>&nbsp;&nbsp;How can I prove that two constructors are different?</H4><!--SEC END -->
 
2680
 
 
2681
You can use the <TT>discriminate</TT> tactic.<BR>
 
2682
<BR>
 
2683
 
 
2684
<DIV ALIGN=left>
 
2685
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;toto&nbsp;:&nbsp;Set&nbsp;:=&nbsp;|&nbsp;C1&nbsp;:&nbsp;toto&nbsp;|&nbsp;C2&nbsp;:&nbsp;toto.</TT><BR>
 
2686
<TT><I>toto&nbsp;is&nbsp;defined</I></TT><BR>
 
2687
<TT><I>toto_rect&nbsp;is&nbsp;defined</I></TT><BR>
 
2688
<TT><I>toto_ind&nbsp;is&nbsp;defined</I></TT><BR>
 
2689
<TT><I>toto_rec&nbsp;is&nbsp;defined</I></TT><BR>
 
2690
<BR>
 
2691
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;C1&nbsp;&lt;&gt;&nbsp;C2.</TT><BR>
 
2692
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2693
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2694
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2695
<TT><I>&nbsp;&nbsp;&nbsp;C1&nbsp;&lt;&gt;&nbsp;C2</I></TT><BR>
 
2696
<BR>
 
2697
<TT>Coq&nbsp;&lt;&nbsp;discriminate.</TT><BR>
 
2698
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2699
<BR>
 
2700
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2701
<TT><I>discriminate.</I></TT><BR>
 
2702
<TT><I>Unnamed_thm22&nbsp;is&nbsp;defined</I></TT><BR>
 
2703
</DIV>
 
2704
<BR>
 
2705
<!--TOC subsubsection During an inductive proof, how to get rid of impossible cases of an inductive definition?-->
 
2706
 
 
2707
<H4><A NAME="htoc121">107</A>&nbsp;&nbsp;During an inductive proof, how to get rid of impossible cases of an inductive definition?</H4><!--SEC END -->
 
2708
 
 
2709
Use the <TT>inversion</TT> tactic.<BR>
 
2710
<BR>
 
2711
<!--TOC subsubsection How can I prove that 2 terms in an inductive set are equal? Or different?-->
 
2712
 
 
2713
<H4><A NAME="htoc122">108</A>&nbsp;&nbsp;How can I prove that 2 terms in an inductive set are equal? Or different?</H4><!--SEC END -->
 
2714
 
 
2715
Have a look at "decide equality" and "discriminate" in the <A HREF="http://coq.inria.fr/doc/main.html">Reference Manual</A>.<BR>
 
2716
<BR>
 
2717
<!--TOC subsubsection Why is the proof of <TT>0+n=n</TT> on natural numbers
 
2718
trivial but the proof of <TT>n+0=n</TT> is not?-->
 
2719
 
 
2720
<H4><A NAME="htoc123">109</A>&nbsp;&nbsp;Why is the proof of <TT>0+n=n</TT> on natural numbers
 
2721
trivial but the proof of <TT>n+0=n</TT> is not?</H4><!--SEC END -->
 
2722
 
 
2723
Since <TT>+</TT> (<TT>plus</TT>) on natural numbers is defined by analysis on its first argument<BR>
 
2724
<BR>
 
2725
 
 
2726
<DIV ALIGN=left>
 
2727
<TT>Coq&nbsp;&lt;&nbsp;Print&nbsp;plus.</TT><BR>
 
2728
<TT><I>plus&nbsp;=&nbsp;</I></TT><BR>
 
2729
<TT><I>(fix&nbsp;plus&nbsp;(n&nbsp;m&nbsp;:&nbsp;nat)&nbsp;{struct&nbsp;n}&nbsp;:&nbsp;nat&nbsp;:=</I></TT><BR>
 
2730
<TT><I>&nbsp;&nbsp;&nbsp;match&nbsp;n&nbsp;with</I></TT><BR>
 
2731
<TT><I>&nbsp;&nbsp;&nbsp;|&nbsp;O&nbsp;=&gt;&nbsp;m</I></TT><BR>
 
2732
<TT><I>&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;p&nbsp;=&gt;&nbsp;S&nbsp;(plus&nbsp;p&nbsp;m)</I></TT><BR>
 
2733
<TT><I>&nbsp;&nbsp;&nbsp;end)</I></TT><BR>
 
2734
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;nat&nbsp;-&gt;&nbsp;nat&nbsp;-&gt;&nbsp;nat</I></TT><BR>
 
2735
<TT><I>Argument&nbsp;scopes&nbsp;are&nbsp;[nat_scope&nbsp;nat_scope]</I></TT><BR>
 
2736
</DIV>
 
2737
<BR>
 
2738
 The expression <TT>0+n</TT> evaluates to <TT>n</TT>. As <FONT COLOR=navy>Coq</FONT> reasons
 
2739
modulo evaluation of expressions, <TT>0+n</TT> and <TT>n</TT> are
 
2740
considered equal and the theorem <TT>0+n=n</TT> is an instance of the
 
2741
reflexivity of equality. On the other side, <TT>n+0</TT> does not
 
2742
evaluate to <TT>n</TT> and a proof by induction on <TT>n</TT> is
 
2743
necessary to trigger the evaluation of <TT>+</TT>.<BR>
 
2744
<BR>
 
2745
<!--TOC subsubsection Why is dependent elimination in Prop not
 
2746
available by default?-->
 
2747
 
 
2748
<H4><A NAME="htoc124">110</A>&nbsp;&nbsp;Why is dependent elimination in Prop not
 
2749
available by default?</H4><!--SEC END -->
 
2750
 
 
2751
This is just because most of the time it is not needed. To derive a
 
2752
dependent elimination principle in <TT>Prop</TT>, use the command <TT>Scheme</TT> and
 
2753
apply the elimination scheme using the <CODE>using</CODE> option of
 
2754
<CODE>elim</CODE>, <CODE>destruct</CODE> or <CODE>induction</CODE>.<BR>
 
2755
<BR>
 
2756
<!--TOC subsection Recursion-->
 
2757
 
 
2758
<H3><A NAME="htoc125">7.2</A>&nbsp;&nbsp;Recursion</H3><!--SEC END -->
 
2759
 
 
2760
<!--TOC subsubsection Why can't I define a non terminating program?-->
 
2761
 
 
2762
<H4><A NAME="htoc126">111</A>&nbsp;&nbsp;Why can't I define a non terminating program?</H4><!--SEC END -->
 
2763
 
 
2764
Because otherwise the decidability of the type-checking
 
2765
algorithm (which involves evaluation of programs) is not ensured. On
 
2766
another side, if non terminating proofs were allowed, we could get a
 
2767
proof of <TT>False</TT>:<BR>
 
2768
<BR>
 
2769
 
 
2770
<DIV ALIGN=left>
 
2771
<TT>Coq&nbsp;&lt;&nbsp;(*&nbsp;This&nbsp;is&nbsp;fortunately&nbsp;not&nbsp;allowed!&nbsp;*)</TT><BR>
 
2772
<TT>Coq&nbsp;&lt;&nbsp;Fixpoint&nbsp;InfiniteProof&nbsp;(n:nat)&nbsp;:&nbsp;False&nbsp;:=&nbsp;InfiniteProof&nbsp;n.</TT><BR>
 
2773
<BR>
 
2774
<TT>Coq&nbsp;&lt;&nbsp;Theorem&nbsp;Paradox&nbsp;:&nbsp;False.</TT><BR>
 
2775
<BR>
 
2776
<TT>Coq&nbsp;&lt;&nbsp;Proof&nbsp;(InfiniteProof&nbsp;O).</TT><BR>
 
2777
</DIV>
 
2778
<BR>
 
2779
<!--TOC subsubsection Why only structurally well-founded loops are allowed?-->
 
2780
 
 
2781
<H4><A NAME="htoc127">112</A>&nbsp;&nbsp;Why only structurally well-founded loops are allowed?</H4><!--SEC END -->
 
2782
 
 
2783
The structural order on inductive types is a simple and
 
2784
powerful notion of termination. The consistency of the Calculus of
 
2785
Inductive Constructions relies on it and another consistency proof
 
2786
would have to be made for stronger termination arguments (such
 
2787
as the termination of the evaluation of CIC programs themselves!).<BR>
 
2788
<BR>
 
2789
In spite of this, all non-pathological termination orders can be mapped
 
2790
to a structural order. Tools to do this are provided in the file 
 
2791
<A HREF="http://coq.inria.fr/library/Coq.Init.Wf.html
 
2792
"><TT>Wf.v</TT></A> of the standard library of <FONT COLOR=navy>Coq</FONT>.<BR>
 
2793
<BR>
 
2794
<!--TOC subsubsection How to define loops based on non structurally smaller
 
2795
recursive calls?-->
 
2796
 
 
2797
<H4><A NAME="htoc128">113</A>&nbsp;&nbsp;How to define loops based on non structurally smaller
 
2798
recursive calls?</H4><!--SEC END -->
 
2799
 
 
2800
The procedure is as follows (we consider the definition of <TT>mergesort</TT> as an example).
 
2801
<UL><LI>Define the termination order, say <TT>R</TT> on the type <TT>A</TT> of
 
2802
the arguments of the loop.<BR>
 
2803
<BR>
 
2804
 
 
2805
<DIV ALIGN=left>
 
2806
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;R&nbsp;(a&nbsp;b:list&nbsp;nat)&nbsp;:=&nbsp;length&nbsp;a&nbsp;&lt;&nbsp;length&nbsp;b.</TT><BR>
 
2807
</DIV>
 
2808
<BR>
 
2809
<BR>
 
2810
<LI>Prove that this order is well-founded (in fact that all elements in <TT>A</TT> are accessible along <TT>R</TT>).<BR>
 
2811
<BR>
 
2812
 
 
2813
<DIV ALIGN=left>
 
2814
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;Rwf&nbsp;:&nbsp;well_founded&nbsp;(A:=R).</TT><BR>
 
2815
</DIV>
 
2816
<BR>
 
2817
<BR>
 
2818
<LI>Define the step function (which needs proofs that recursive
 
2819
calls are on smaller arguments).<BR>
 
2820
<BR>
 
2821
 
 
2822
<DIV ALIGN=left>
 
2823
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;split&nbsp;(l&nbsp;:&nbsp;list&nbsp;nat)&nbsp;</TT><BR>
 
2824
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;{l1:&nbsp;list&nbsp;nat&nbsp;|&nbsp;R&nbsp;l1&nbsp;l}&nbsp;*&nbsp;{l2&nbsp;:&nbsp;list&nbsp;nat&nbsp;|&nbsp;R&nbsp;l2&nbsp;l}</TT><BR>
 
2825
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;:=&nbsp;(*&nbsp;...&nbsp;*)&nbsp;.</TT><BR>
 
2826
<BR>
 
2827
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;concat&nbsp;(l1&nbsp;l2&nbsp;:&nbsp;list&nbsp;nat)&nbsp;:&nbsp;list&nbsp;nat&nbsp;:=&nbsp;(*&nbsp;...&nbsp;*)&nbsp;.</TT><BR>
 
2828
<BR>
 
2829
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;merge_step&nbsp;(l&nbsp;:&nbsp;list&nbsp;nat)&nbsp;(f:&nbsp;forall&nbsp;l':list&nbsp;nat,&nbsp;R&nbsp;l'&nbsp;l&nbsp;-&gt;&nbsp;list&nbsp;nat)&nbsp;:=</TT><BR>
 
2830
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;let&nbsp;(lH1,lH2)&nbsp;:=&nbsp;(split&nbsp;l)&nbsp;in</TT><BR>
 
2831
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;let&nbsp;(l1,H1)&nbsp;:=&nbsp;lH1&nbsp;in</TT><BR>
 
2832
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;let&nbsp;(l2,H2)&nbsp;:=&nbsp;lH2&nbsp;in</TT><BR>
 
2833
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;concat&nbsp;(f&nbsp;l1&nbsp;H1)&nbsp;(f&nbsp;l2&nbsp;H2).</TT><BR>
 
2834
</DIV>
 
2835
<BR>
 
2836
<BR>
 
2837
<LI>Define the recursive function by fixpoint on the step function.<BR>
 
2838
<BR>
 
2839
 
 
2840
<DIV ALIGN=left>
 
2841
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;merge&nbsp;:=&nbsp;Fix&nbsp;Rwf&nbsp;(fun&nbsp;_&nbsp;=&gt;&nbsp;list&nbsp;nat)&nbsp;merge_step.</TT><BR>
 
2842
</DIV>
 
2843
</UL>
 
2844
<!--TOC subsubsection What is behind the accessibility and well-foundedness proofs?-->
 
2845
 
 
2846
<H4><A NAME="htoc129">114</A>&nbsp;&nbsp;What is behind the accessibility and well-foundedness proofs?</H4><!--SEC END -->
 
2847
 
 
2848
Well-foundedness of some relation <TT>R</TT> on some type <TT>A</TT>
 
2849
is defined as the accessibility of all elements of <TT>A</TT> along <TT>R</TT>.<BR>
 
2850
<BR>
 
2851
 
 
2852
<DIV ALIGN=left>
 
2853
<TT>Coq&nbsp;&lt;&nbsp;Print&nbsp;well_founded.</TT><BR>
 
2854
<TT><I>well_founded&nbsp;=&nbsp;</I></TT><BR>
 
2855
<TT><I>fun&nbsp;(A&nbsp;:&nbsp;Set)&nbsp;(R&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;Prop)&nbsp;=&gt;&nbsp;forall&nbsp;a&nbsp;:&nbsp;A,&nbsp;Acc&nbsp;R&nbsp;a</I></TT><BR>
 
2856
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;forall&nbsp;A&nbsp;:&nbsp;Set,&nbsp;(A&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;Prop)&nbsp;-&gt;&nbsp;Prop</I></TT><BR>
 
2857
<TT><I>Argument&nbsp;A&nbsp;is&nbsp;implicit</I></TT><BR>
 
2858
<TT><I>Argument&nbsp;scopes&nbsp;are&nbsp;[type_scope&nbsp;_]</I></TT><BR>
 
2859
<BR>
 
2860
<TT>Coq&nbsp;&lt;&nbsp;Print&nbsp;Acc.</TT><BR>
 
2861
<TT><I>Inductive&nbsp;Acc&nbsp;(A&nbsp;:&nbsp;Set)&nbsp;(R&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;A&nbsp;-&gt;&nbsp;Prop)&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;Prop&nbsp;:=</I></TT><BR>
 
2862
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;Acc_intro&nbsp;:&nbsp;forall&nbsp;x&nbsp;:&nbsp;A,&nbsp;(forall&nbsp;y&nbsp;:&nbsp;A,&nbsp;R&nbsp;y&nbsp;x&nbsp;-&gt;&nbsp;Acc&nbsp;R&nbsp;y)&nbsp;-&gt;&nbsp;Acc&nbsp;R&nbsp;x</I></TT><BR>
 
2863
<TT><I>For&nbsp;Acc:&nbsp;Argument&nbsp;A&nbsp;is&nbsp;implicit</I></TT><BR>
 
2864
<TT><I>For&nbsp;Acc_intro:&nbsp;Arguments&nbsp;A,&nbsp;R&nbsp;are&nbsp;implicit</I></TT><BR>
 
2865
<TT><I>For&nbsp;Acc:&nbsp;Argument&nbsp;scopes&nbsp;are&nbsp;[type_scope&nbsp;_&nbsp;_]</I></TT><BR>
 
2866
<TT><I>For&nbsp;Acc_intro:&nbsp;Argument&nbsp;scopes&nbsp;are&nbsp;[type_scope&nbsp;_&nbsp;_&nbsp;_]</I></TT><BR>
 
2867
</DIV>
 
2868
<BR>
 
2869
The structure of the accessibility predicate is a well-founded tree
 
2870
branching at each node <TT>x</TT> in <TT>A</TT> along all the nodes <TT>x'</TT>
 
2871
less than <TT>x</TT> along <TT>R</TT>. Any sequence of elements of <TT>A</TT>
 
2872
decreasing along the order <TT>R</TT> are branches in the accessibility
 
2873
tree. Hence any decreasing along <TT>R</TT> is mapped into a structural
 
2874
decreasing in the accessibility tree of <TT>R</TT>. This is emphasised in
 
2875
the definition of <TT>fix</TT> which recurs not on its argument <TT>x:A</TT>
 
2876
but on the accessibility of this argument along <TT>R</TT>.<BR>
 
2877
<BR>
 
2878
See file <A HREF="http://coq.inria.fr/library/Coq.Init.Wf.html
 
2879
"><TT>Wf.v</TT></A>.<BR>
 
2880
<BR>
 
2881
<!--TOC subsubsection How to perform double induction?-->
 
2882
 
 
2883
<H4><A NAME="htoc130">115</A>&nbsp;&nbsp;How to perform double induction?</H4><!--SEC END -->
 
2884
 
 
2885
In general a double induction is simply solved by an induction on the
 
2886
first hypothesis followed by an inversion over the second
 
2887
hypothesis. Here is an example<BR>
 
2888
<BR>
 
2889
 
 
2890
<DIV ALIGN=left>
 
2891
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;even&nbsp;:&nbsp;nat&nbsp;-&gt;&nbsp;Prop&nbsp;:=</TT><BR>
 
2892
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;even_O&nbsp;:&nbsp;even&nbsp;0</TT><BR>
 
2893
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;even_S&nbsp;:&nbsp;forall&nbsp;n:nat,&nbsp;even&nbsp;n&nbsp;-&gt;&nbsp;even&nbsp;(S&nbsp;(S&nbsp;n)).</TT><BR>
 
2894
<TT><I>even&nbsp;is&nbsp;defined</I></TT><BR>
 
2895
<TT><I>even_ind&nbsp;is&nbsp;defined</I></TT><BR>
 
2896
<BR>
 
2897
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
2898
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;odd&nbsp;:&nbsp;nat&nbsp;-&gt;&nbsp;Prop&nbsp;:=</TT><BR>
 
2899
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;odd_SO&nbsp;:&nbsp;odd&nbsp;1</TT><BR>
 
2900
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;odd_S&nbsp;:&nbsp;forall&nbsp;n:nat,&nbsp;odd&nbsp;n&nbsp;-&gt;&nbsp;odd&nbsp;(S&nbsp;(S&nbsp;n)).</TT><BR>
 
2901
<TT><I>odd&nbsp;is&nbsp;defined</I></TT><BR>
 
2902
<TT><I>odd_ind&nbsp;is&nbsp;defined</I></TT><BR>
 
2903
<BR>
 
2904
<TT>Coq&nbsp;&lt;&nbsp;</TT><BR>
 
2905
<TT>Coq&nbsp;&lt;&nbsp;Goal&nbsp;forall&nbsp;n:nat,&nbsp;even&nbsp;n&nbsp;-&gt;&nbsp;odd&nbsp;n&nbsp;-&gt;&nbsp;False.</TT><BR>
 
2906
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2907
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2908
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2909
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;n&nbsp;:&nbsp;nat,&nbsp;even&nbsp;n&nbsp;-&gt;&nbsp;odd&nbsp;n&nbsp;-&gt;&nbsp;False</I></TT><BR>
 
2910
<BR>
 
2911
<TT>Coq&nbsp;&lt;&nbsp;induction&nbsp;1.</TT><BR>
 
2912
<TT><I>2&nbsp;subgoals</I></TT><BR>
 
2913
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2914
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2915
<TT><I>&nbsp;&nbsp;&nbsp;odd&nbsp;0&nbsp;-&gt;&nbsp;False</I></TT><BR>
 
2916
<TT><I>subgoal&nbsp;2&nbsp;is:</I></TT><BR>
 
2917
<TT><I>&nbsp;odd&nbsp;(S&nbsp;(S&nbsp;n))&nbsp;-&gt;&nbsp;False</I></TT><BR>
 
2918
<BR>
 
2919
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;inversion&nbsp;1.</TT><BR>
 
2920
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2921
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2922
<TT><I>&nbsp;&nbsp;n&nbsp;:&nbsp;nat</I></TT><BR>
 
2923
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;even&nbsp;n</I></TT><BR>
 
2924
<TT><I>&nbsp;&nbsp;IHeven&nbsp;:&nbsp;odd&nbsp;n&nbsp;-&gt;&nbsp;False</I></TT><BR>
 
2925
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2926
<TT><I>&nbsp;&nbsp;&nbsp;odd&nbsp;(S&nbsp;(S&nbsp;n))&nbsp;-&gt;&nbsp;False</I></TT><BR>
 
2927
<BR>
 
2928
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;inversion&nbsp;1.&nbsp;apply&nbsp;IHeven;&nbsp;trivial.</TT><BR>
 
2929
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
2930
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
2931
<TT><I>&nbsp;&nbsp;n&nbsp;:&nbsp;nat</I></TT><BR>
 
2932
<TT><I>&nbsp;&nbsp;H&nbsp;:&nbsp;even&nbsp;n</I></TT><BR>
 
2933
<TT><I>&nbsp;&nbsp;IHeven&nbsp;:&nbsp;odd&nbsp;n&nbsp;-&gt;&nbsp;False</I></TT><BR>
 
2934
<TT><I>&nbsp;&nbsp;H0&nbsp;:&nbsp;odd&nbsp;(S&nbsp;(S&nbsp;n))</I></TT><BR>
 
2935
<TT><I>&nbsp;&nbsp;n0&nbsp;:&nbsp;nat</I></TT><BR>
 
2936
<TT><I>&nbsp;&nbsp;H2&nbsp;:&nbsp;odd&nbsp;n</I></TT><BR>
 
2937
<TT><I>&nbsp;&nbsp;H1&nbsp;:&nbsp;n0&nbsp;=&nbsp;n</I></TT><BR>
 
2938
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
2939
<TT><I>&nbsp;&nbsp;&nbsp;False</I></TT><BR>
 
2940
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
2941
<BR>
 
2942
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
2943
<TT><I>induction&nbsp;1.</I></TT><BR>
 
2944
<TT><I>&nbsp;inversion&nbsp;1.</I></TT><BR>
 
2945
<TT><I>&nbsp;inversion&nbsp;1.</I></TT><BR>
 
2946
<TT><I>&nbsp;&nbsp;&nbsp;apply&nbsp;IHeven;&nbsp;trivial.</I></TT><BR>
 
2947
<TT><I>Unnamed_thm&nbsp;is&nbsp;defined</I></TT><BR>
 
2948
</DIV>
 
2949
<BR>
 
2950
In case the type of the second induction hypothesis is not
 
2951
dependent, <TT>inversion</TT> can just be replaced by <TT>destruct</TT>.<BR>
 
2952
<BR>
 
2953
<!--TOC subsubsection How to define a function by double recursion?-->
 
2954
 
 
2955
<H4><A NAME="htoc131">116</A>&nbsp;&nbsp;How to define a function by double recursion?</H4><!--SEC END -->
 
2956
 
 
2957
The same trick applies, you can even use the pattern-matching
 
2958
compilation algorithm to do the work for you. Here is an example:<BR>
 
2959
<BR>
 
2960
 
 
2961
<DIV ALIGN=left>
 
2962
<TT>Coq&nbsp;&lt;&nbsp;Fixpoint&nbsp;minus&nbsp;(n&nbsp;m:nat)&nbsp;{struct&nbsp;n}&nbsp;:&nbsp;nat&nbsp;:=</TT><BR>
 
2963
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;match&nbsp;n,&nbsp;m&nbsp;with</TT><BR>
 
2964
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;O,&nbsp;_&nbsp;=&gt;&nbsp;0</TT><BR>
 
2965
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;k,&nbsp;O&nbsp;=&gt;&nbsp;S&nbsp;k</TT><BR>
 
2966
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;k,&nbsp;S&nbsp;l&nbsp;=&gt;&nbsp;minus&nbsp;k&nbsp;l</TT><BR>
 
2967
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;end.</TT><BR>
 
2968
<TT><I>minus&nbsp;is&nbsp;recursively&nbsp;defined</I></TT><BR>
 
2969
<BR>
 
2970
<TT>Coq&nbsp;&lt;&nbsp;Print&nbsp;&nbsp;minus.</TT><BR>
 
2971
<TT><I>minus&nbsp;=&nbsp;</I></TT><BR>
 
2972
<TT><I>(fix&nbsp;minus&nbsp;(n&nbsp;m&nbsp;:&nbsp;nat)&nbsp;{struct&nbsp;n}&nbsp;:&nbsp;nat&nbsp;:=</I></TT><BR>
 
2973
<TT><I>&nbsp;&nbsp;&nbsp;match&nbsp;n&nbsp;with</I></TT><BR>
 
2974
<TT><I>&nbsp;&nbsp;&nbsp;|&nbsp;O&nbsp;=&gt;&nbsp;0</I></TT><BR>
 
2975
<TT><I>&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;k&nbsp;=&gt;&nbsp;match&nbsp;m&nbsp;with</I></TT><BR>
 
2976
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;O&nbsp;=&gt;&nbsp;S&nbsp;k</I></TT><BR>
 
2977
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;l&nbsp;=&gt;&nbsp;minus&nbsp;k&nbsp;l</I></TT><BR>
 
2978
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end</I></TT><BR>
 
2979
<TT><I>&nbsp;&nbsp;&nbsp;end)</I></TT><BR>
 
2980
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;nat&nbsp;-&gt;&nbsp;nat&nbsp;-&gt;&nbsp;nat</I></TT><BR>
 
2981
<TT><I>Argument&nbsp;scopes&nbsp;are&nbsp;[nat_scope&nbsp;nat_scope]</I></TT><BR>
 
2982
</DIV>
 
2983
<BR>
 
2984
In case of dependencies in the type of the induction objects
 
2985
<I>t</I><SUB><FONT SIZE=2>1</FONT></SUB> and <I>t</I><SUB><FONT SIZE=2>2</FONT></SUB>, an extra argument stating <I>t</I><SUB><FONT SIZE=2>1</FONT></SUB>=<I>t</I><SUB><FONT SIZE=2>2</FONT></SUB> must be given to
 
2986
the fixpoint definition<BR>
 
2987
<BR>
 
2988
<!--TOC subsubsection How to perform nested induction?-->
 
2989
 
 
2990
<H4><A NAME="htoc132">117</A>&nbsp;&nbsp;How to perform nested induction?</H4><!--SEC END -->
 
2991
 
 
2992
To reason by nested induction, just reason by induction on the
 
2993
successive components.<BR>
 
2994
<BR>
 
2995
 
 
2996
<DIV ALIGN=left>
 
2997
<TT>Coq&nbsp;&lt;&nbsp;Infix&nbsp;"&lt;"&nbsp;:=&nbsp;lt&nbsp;(at&nbsp;level&nbsp;70,&nbsp;no&nbsp;associativity).</TT><BR>
 
2998
<BR>
 
2999
<TT>Coq&nbsp;&lt;&nbsp;Infix&nbsp;"&lt;="&nbsp;:=&nbsp;le&nbsp;(at&nbsp;level&nbsp;70,&nbsp;no&nbsp;associativity).</TT><BR>
 
3000
<BR>
 
3001
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;le_or_lt&nbsp;:&nbsp;forall&nbsp;n&nbsp;n0:nat,&nbsp;n0&nbsp;&lt;&nbsp;n&nbsp;\/&nbsp;n&nbsp;&lt;=&nbsp;n0.</TT><BR>
 
3002
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
3003
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
3004
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
3005
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;n&nbsp;n0&nbsp;:&nbsp;nat,&nbsp;n0&nbsp;&lt;&nbsp;n&nbsp;\/&nbsp;n&nbsp;&lt;=&nbsp;n0</I></TT><BR>
 
3006
<BR>
 
3007
<TT>Coq&nbsp;&lt;&nbsp;induction&nbsp;n;&nbsp;destruct&nbsp;n0;&nbsp;auto&nbsp;with&nbsp;arith.</TT><BR>
 
3008
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
3009
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
3010
<TT><I>&nbsp;&nbsp;n&nbsp;:&nbsp;nat</I></TT><BR>
 
3011
<TT><I>&nbsp;&nbsp;IHn&nbsp;:&nbsp;forall&nbsp;n0&nbsp;:&nbsp;nat,&nbsp;n0&nbsp;&lt;&nbsp;n&nbsp;\/&nbsp;n&nbsp;&lt;=&nbsp;n0</I></TT><BR>
 
3012
<TT><I>&nbsp;&nbsp;n0&nbsp;:&nbsp;nat</I></TT><BR>
 
3013
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
3014
<TT><I>&nbsp;&nbsp;&nbsp;S&nbsp;n0&nbsp;&lt;&nbsp;S&nbsp;n&nbsp;\/&nbsp;S&nbsp;n&nbsp;&lt;=&nbsp;S&nbsp;n0</I></TT><BR>
 
3015
<BR>
 
3016
<TT>Coq&nbsp;&lt;&nbsp;destruct&nbsp;(IHn&nbsp;n0);&nbsp;auto&nbsp;with&nbsp;arith.</TT><BR>
 
3017
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
3018
</DIV>
 
3019
<BR>
 
3020
<!--TOC subsubsection How to define a function by nested recursion?-->
 
3021
 
 
3022
<H4><A NAME="htoc133">118</A>&nbsp;&nbsp;How to define a function by nested recursion?</H4><!--SEC END -->
 
3023
 
 
3024
The same trick applies. Here is the example of Ackermann
 
3025
function.<BR>
 
3026
<BR>
 
3027
 
 
3028
<DIV ALIGN=left>
 
3029
<TT>Coq&nbsp;&lt;&nbsp;Fixpoint&nbsp;ack&nbsp;(n:nat)&nbsp;:&nbsp;nat&nbsp;-&gt;&nbsp;nat&nbsp;:=</TT><BR>
 
3030
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;match&nbsp;n&nbsp;with</TT><BR>
 
3031
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;O&nbsp;=&gt;&nbsp;S</TT><BR>
 
3032
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;n'&nbsp;=&gt;</TT><BR>
 
3033
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fix&nbsp;ack'&nbsp;(m:nat)&nbsp;:&nbsp;nat&nbsp;:=</TT><BR>
 
3034
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;match&nbsp;m&nbsp;with</TT><BR>
 
3035
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;O&nbsp;=&gt;&nbsp;ack&nbsp;n'&nbsp;1</TT><BR>
 
3036
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;S&nbsp;m'&nbsp;=&gt;&nbsp;ack&nbsp;n'&nbsp;(ack'&nbsp;m')</TT><BR>
 
3037
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end)</TT><BR>
 
3038
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;end.</TT><BR>
 
3039
<TT><I>ack&nbsp;is&nbsp;recursively&nbsp;defined</I></TT><BR>
 
3040
</DIV>
 
3041
<BR>
 
3042
<!--TOC subsection Co-inductive types-->
 
3043
 
 
3044
<H3><A NAME="htoc134">7.3</A>&nbsp;&nbsp;Co-inductive types</H3><!--SEC END -->
 
3045
 
 
3046
<!--TOC subsubsection I have a cofixpoint <I>t</I>:=<I>F</I>(<I>t</I>) and I want to prove <I>t</I>=<I>F</I>(<I>t</I>). How to do it?-->
 
3047
 
 
3048
<H4><A NAME="htoc135">119</A>&nbsp;&nbsp;I have a cofixpoint <I>t</I>:=<I>F</I>(<I>t</I>) and I want to prove <I>t</I>=<I>F</I>(<I>t</I>). How to do it?</H4><!--SEC END -->
 
3049
 
 
3050
Just case-expand <I>F</I>(<TT><I>t</I></TT>) then complete by a trivial case analysis.
 
3051
Here is what it gives on e.g. the type of streams on naturals<BR>
 
3052
<BR>
 
3053
 
 
3054
<DIV ALIGN=left>
 
3055
<TT>Coq&nbsp;&lt;&nbsp;CoInductive&nbsp;Stream&nbsp;(A:Set)&nbsp;:&nbsp;Set&nbsp;:=</TT><BR>
 
3056
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;Cons&nbsp;:&nbsp;A&nbsp;-&gt;&nbsp;Stream&nbsp;A&nbsp;-&gt;&nbsp;Stream&nbsp;A.</TT><BR>
 
3057
<TT><I>Stream&nbsp;is&nbsp;defined</I></TT><BR>
 
3058
<BR>
 
3059
<TT>Coq&nbsp;&lt;&nbsp;CoFixpoint&nbsp;nats&nbsp;(n:nat)&nbsp;:&nbsp;Stream&nbsp;nat&nbsp;:=&nbsp;Cons&nbsp;n&nbsp;(nats&nbsp;(S&nbsp;n)).</TT><BR>
 
3060
<TT><I>nats&nbsp;is&nbsp;corecursively&nbsp;defined</I></TT><BR>
 
3061
<BR>
 
3062
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;Stream_unfold&nbsp;:&nbsp;</TT><BR>
 
3063
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;n:nat,&nbsp;nats&nbsp;n&nbsp;=&nbsp;Cons&nbsp;n&nbsp;(nats&nbsp;(S&nbsp;n)).</TT><BR>
 
3064
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
3065
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
3066
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
3067
<TT><I>&nbsp;&nbsp;&nbsp;forall&nbsp;n&nbsp;:&nbsp;nat,&nbsp;nats&nbsp;n&nbsp;=&nbsp;Cons&nbsp;n&nbsp;(nats&nbsp;(S&nbsp;n))</I></TT><BR>
 
3068
<BR>
 
3069
<TT>Coq&nbsp;&lt;&nbsp;Proof.</TT><BR>
 
3070
<BR>
 
3071
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;intro;</TT><BR>
 
3072
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;change&nbsp;(nats&nbsp;n&nbsp;=&nbsp;match&nbsp;nats&nbsp;n&nbsp;with</TT><BR>
 
3073
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Cons&nbsp;x&nbsp;s&nbsp;=&gt;&nbsp;Cons&nbsp;x&nbsp;s</TT><BR>
 
3074
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end).</TT><BR>
 
3075
<TT><I>1&nbsp;subgoal</I></TT><BR>
 
3076
<TT><I>&nbsp;&nbsp;</I></TT><BR>
 
3077
<TT><I>&nbsp;&nbsp;n&nbsp;:&nbsp;nat</I></TT><BR>
 
3078
<TT><I>&nbsp;&nbsp;============================</I></TT><BR>
 
3079
<TT><I>&nbsp;&nbsp;&nbsp;nats&nbsp;n&nbsp;=&nbsp;match&nbsp;nats&nbsp;n&nbsp;with</I></TT><BR>
 
3080
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Cons&nbsp;x&nbsp;s&nbsp;=&gt;&nbsp;Cons&nbsp;x&nbsp;s</I></TT><BR>
 
3081
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end</I></TT><BR>
 
3082
<BR>
 
3083
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;case&nbsp;(nats&nbsp;n);&nbsp;reflexivity.</TT><BR>
 
3084
<TT><I>Proof&nbsp;completed.</I></TT><BR>
 
3085
<BR>
 
3086
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3087
<TT><I>intro;&nbsp;change&nbsp;(nats&nbsp;n&nbsp;=&nbsp;match&nbsp;nats&nbsp;n&nbsp;with</I></TT><BR>
 
3088
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Cons&nbsp;x&nbsp;s&nbsp;=&gt;&nbsp;Cons&nbsp;x&nbsp;s</I></TT><BR>
 
3089
<TT><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end)&nbsp;in&nbsp;|-&nbsp;*.</I></TT><BR>
 
3090
<TT><I>case&nbsp;(nats&nbsp;n);&nbsp;reflexivity.</I></TT><BR>
 
3091
<TT><I>Stream_unfold&nbsp;is&nbsp;defined</I></TT><BR>
 
3092
</DIV>
 
3093
<BR>
 
3094
<!--TOC section Syntax and notations-->
 
3095
 
 
3096
<H2><A NAME="htoc136">8</A>&nbsp;&nbsp;Syntax and notations</H2><!--SEC END -->
 
3097
 
 
3098
<!--TOC subsubsection I do not want to type ``forall'' because it is too long, what can I do?-->
 
3099
 
 
3100
<H4><A NAME="htoc137">120</A>&nbsp;&nbsp;I do not want to type ``forall'' because it is too long, what can I do?</H4><!--SEC END -->
 
3101
 
 
3102
You can define your own notation for forall:
 
3103
<PRE>
 
3104
Notation "fa x : t, P" := (forall x:t, P) (at level 200, x ident).
 
3105
</PRE>or if your are using <FONT COLOR=navy>CoqIde</FONT> you can define a pretty symbol for for all and an input method (see <A HREF="#forallcoqide">150</A>).<BR>
 
3106
<BR>
 
3107
<!--TOC subsubsection How can I define a notation for square?-->
 
3108
 
 
3109
<H4><A NAME="htoc138">121</A>&nbsp;&nbsp;How can I define a notation for square?</H4><!--SEC END -->
 
3110
 
 
3111
You can use for instance:
 
3112
<PRE>
 
3113
Notation "x ^2" := (Rmult x x) (at level 20).
 
3114
</PRE>Note that you can not use:
 
3115
<TT>N</TT>otation "x <SUP><FONT SIZE=2>�</FONT></SUP>" := (Rmult x x) (at level 20).
 
3116
 
 
3117
because ``<SUP><FONT SIZE=2>2</FONT></SUP>'' is an iso-latin character. If you really want this kind of notation you should use UTF-8.<BR>
 
3118
<BR>
 
3119
<!--TOC subsubsection Why ``no associativity'' and ``left associativity'' at the same level does not work?-->
 
3120
 
 
3121
<H4><A NAME="htoc139">122</A>&nbsp;&nbsp;Why ``no associativity'' and ``left associativity'' at the same level does not work?</H4><!--SEC END -->
 
3122
 
 
3123
Because we relie on camlp4 for syntactical analysis and camlp4 does not really implement no associativity. By default, non associative operators are defined as right associative.<BR>
 
3124
<BR>
 
3125
<!--TOC subsubsection How can I know the associativity associated with a level?-->
 
3126
 
 
3127
<H4><A NAME="htoc140">123</A>&nbsp;&nbsp;How can I know the associativity associated with a level?</H4><!--SEC END -->
 
3128
 
 
3129
You can do ``Print Grammar constr'', and decode the output from camlp4, good luck !<BR>
 
3130
<BR>
 
3131
<!--TOC section Modules-->
 
3132
 
 
3133
<H2><A NAME="htoc141">9</A>&nbsp;&nbsp;Modules</H2><!--SEC END -->
 
3134
 
 
3135
<!--TOC section <FONT COLOR=navy>Ltac</FONT>-->
 
3136
 
 
3137
<H2><A NAME="htoc142">10</A>&nbsp;&nbsp;<FONT COLOR=navy>Ltac</FONT></H2><!--SEC END -->
 
3138
 
 
3139
<!--TOC subsubsection What is <FONT COLOR=navy>Ltac</FONT>?-->
 
3140
 
 
3141
<H4><A NAME="htoc143">124</A>&nbsp;&nbsp;What is <FONT COLOR=navy>Ltac</FONT>?</H4><!--SEC END -->
 
3142
 
 
3143
<FONT COLOR=navy>Ltac</FONT> is the tactic language for <FONT COLOR=navy>Coq</FONT>. It provides the user with a
 
3144
high-level ``toolbox'' for tactic creation.<BR>
 
3145
<BR>
 
3146
<!--TOC subsubsection Why do I always get the same error message?-->
 
3147
 
 
3148
<H4><A NAME="htoc144">125</A>&nbsp;&nbsp;Why do I always get the same error message?</H4><!--SEC END -->
 
3149
 
 
3150
<!--TOC subsubsection Is there any printing command in <FONT COLOR=navy>Ltac</FONT>?-->
 
3151
 
 
3152
<H4><A NAME="htoc145">126</A>&nbsp;&nbsp;Is there any printing command in <FONT COLOR=navy>Ltac</FONT>?</H4><!--SEC END -->
 
3153
 
 
3154
You can use the <TT>idtac</TT> tactic with a string argument. This string
 
3155
will be printed out. The same applies to the <TT>fail</TT> tactic<BR>
 
3156
<BR>
 
3157
<!--TOC subsubsection What is the syntax for let in <FONT COLOR=navy>Ltac</FONT>?-->
 
3158
 
 
3159
<H4><A NAME="htoc146">127</A>&nbsp;&nbsp;What is the syntax for let in <FONT COLOR=navy>Ltac</FONT>?</H4><!--SEC END -->
 
3160
 
 
3161
If <I>x</I><SUB><FONT SIZE=2><I>i</I></FONT></SUB> are identifiers and <I>e</I><SUB><FONT SIZE=2><I>i</I></FONT></SUB> and <I>expr</I> are tactic expressions, then let reads:
 
3162
<DIV ALIGN=center>
 
3163
<TT>let <I>x</I></TT><SUB><TT><FONT SIZE=2>1</FONT></TT></SUB><TT>:=<I>e</I></TT><SUB><TT><FONT SIZE=2>1</FONT></TT></SUB><TT> with <I>x</I></TT><SUB><TT><FONT SIZE=2>2</FONT></TT></SUB><TT>:=<I>e</I></TT><SUB><TT><FONT SIZE=2>2</FONT></TT></SUB><TT>...with <I>x</I></TT><SUB><TT><FONT SIZE=2><I>n</I></FONT></TT></SUB><TT>:=<I>e</I></TT><SUB><TT><FONT SIZE=2><I>n</I></FONT></TT></SUB><TT> in
 
3164
<I>expr</I></TT>.
 
3165
</DIV>
 
3166
Beware that if <I>expr</I> is complex (i.e. features at least a sequence) parenthesis
 
3167
should be added around it. For example: 
 
3168
 
 
3169
<DIV ALIGN=left>
 
3170
<TT>Coq&nbsp;&lt;&nbsp;Ltac&nbsp;twoIntro&nbsp;:=&nbsp;let&nbsp;x:=intro&nbsp;in&nbsp;(x;x).</TT><BR>
 
3171
<TT><I>twoIntro&nbsp;is&nbsp;defined</I></TT><BR>
 
3172
</DIV>
 
3173
<BR>
 
3174
<!--TOC subsubsection What is the syntax for pattern matching in <FONT COLOR=navy>Ltac</FONT>?-->
 
3175
 
 
3176
<H4><A NAME="htoc147">128</A>&nbsp;&nbsp;What is the syntax for pattern matching in <FONT COLOR=navy>Ltac</FONT>?</H4><!--SEC END -->
 
3177
 
 
3178
Pattern matching on a term <I>expr</I> (non-linear first order unification)
 
3179
with patterns <I>p</I><SUB><FONT SIZE=2><I>i</I></FONT></SUB> and tactic expressions <I>e</I><SUB><FONT SIZE=2><I>i</I></FONT></SUB> reads:
 
3180
<DIV ALIGN=center>
 
3181
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
3182
<TT>match <I>expr</I> with
 
3183
&nbsp;&nbsp;<I>p</I></TT><SUB><TT><FONT SIZE=2>1</FONT></TT></SUB><TT> =&gt; <I>e</I></TT><SUB><TT><FONT SIZE=2>1</FONT></TT></SUB><TT>
 
3184
&nbsp;|<I>p</I></TT><SUB><TT><FONT SIZE=2>2</FONT></TT></SUB><TT> =&gt; <I>e</I></TT><SUB><TT><FONT SIZE=2>2</FONT></TT></SUB><TT>
 
3185
&nbsp;...&nbsp;|<I>p</I></TT><SUB><TT><FONT SIZE=2><I>n</I></FONT></TT></SUB><TT> =&gt; <I>e</I></TT><SUB><TT><FONT SIZE=2><I>n</I></FONT></TT></SUB><TT>
 
3186
&nbsp;| _ =&gt; <I>e</I></TT><SUB><TT><FONT SIZE=2><I>n</I>+1</FONT></TT></SUB><TT>
 
3187
end.
 
3188
</TT>
 
3189
</DIV>
 
3190
Underscore matches all terms.<BR>
 
3191
<BR>
 
3192
<!--TOC subsubsection What is the semantics for match goal?-->
 
3193
 
 
3194
<H4><A NAME="htoc148">129</A>&nbsp;&nbsp;What is the semantics for match goal?</H4><!--SEC END -->
 
3195
 
 
3196
<TT>match goal</TT> matches the current goal against a series of
 
3197
patterns: <I>hyp</I><SUB><FONT SIZE=2>1</FONT></SUB> ... <I>hyp</I><SUB><FONT SIZE=2><I>n</I></FONT></SUB> |- <I>ccl</I>. It uses a
 
3198
first-order unification algorithm, and tries all the possible
 
3199
combinations of <I>hyp</I><SUB><FONT SIZE=2><I>i</I></FONT></SUB> before dropping the branch and moving to the
 
3200
next one. Underscore matches all terms.<BR>
 
3201
<BR>
 
3202
<!--TOC subsubsection How can I generate a new name?-->
 
3203
 
 
3204
<H4><A NAME="htoc149">130</A>&nbsp;&nbsp;How can I generate a new name?</H4><!--SEC END -->
 
3205
 
 
3206
You can use the following syntax:
 
3207
<TT>let id:=fresh in ...</TT><BR>
 
3208
For example:
 
3209
 
 
3210
<DIV ALIGN=left>
 
3211
<TT>Coq&nbsp;&lt;&nbsp;Ltac&nbsp;introIdGen&nbsp;:=&nbsp;let&nbsp;id:=fresh&nbsp;in&nbsp;intro&nbsp;id.</TT><BR>
 
3212
<TT><I>introIdGen&nbsp;is&nbsp;defined</I></TT><BR>
 
3213
</DIV>
 
3214
<BR>
 
3215
<!--TOC subsubsection How can I define static and dynamic code?-->
 
3216
 
 
3217
<H4><A NAME="htoc150">131</A>&nbsp;&nbsp;How can I define static and dynamic code?</H4><!--SEC END -->
 
3218
 
 
3219
<!--TOC section Tactics written in Ocaml-->
 
3220
 
 
3221
<H2><A NAME="htoc151">11</A>&nbsp;&nbsp;Tactics written in Ocaml</H2><!--SEC END -->
 
3222
 
 
3223
<!--TOC subsubsection Can you show me an example of a tactic written in OCaml?-->
 
3224
 
 
3225
<H4><A NAME="htoc152">132</A>&nbsp;&nbsp;Can you show me an example of a tactic written in OCaml?</H4><!--SEC END -->
 
3226
 
 
3227
You have some examples of tactics written in Ocaml in the ``contrib'' directory of <FONT COLOR=navy>Coq</FONT> sources. <BR>
 
3228
<BR>
 
3229
<!--TOC section Case studies-->
 
3230
 
 
3231
<H2><A NAME="htoc153">12</A>&nbsp;&nbsp;Case studies</H2><!--SEC END -->
 
3232
 
 
3233
<!--TOC subsubsection How can I define vectors or lists of size n?-->
 
3234
 
 
3235
<H4><A NAME="htoc154">133</A>&nbsp;&nbsp;How can I define vectors or lists of size n?</H4><!--SEC END -->
 
3236
 
 
3237
<!--TOC subsubsection How to prove that 2 sets are different?-->
 
3238
 
 
3239
<H4><A NAME="htoc155">134</A>&nbsp;&nbsp;How to prove that 2 sets are different?</H4><!--SEC END -->
 
3240
 
 
3241
You need to find a property true on one set and false on the
 
3242
other one. As an example we show how to prove that <TT>bool</TT> and <TT>nat</TT> are discriminable. As discrimination property we take the
 
3243
property to have no more than 2 elements.<BR>
 
3244
<BR>
 
3245
 
 
3246
<DIV ALIGN=left>
 
3247
<TT>Coq&nbsp;&lt;&nbsp;Theorem&nbsp;nat_bool_discr&nbsp;:&nbsp;bool&nbsp;&lt;&gt;&nbsp;nat.</TT><BR>
 
3248
<BR>
 
3249
<TT>Coq&nbsp;&lt;&nbsp;Proof.</TT><BR>
 
3250
<BR>
 
3251
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;pose&nbsp;(discr&nbsp;:=</TT><BR>
 
3252
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun&nbsp;X:Set&nbsp;=&gt;</TT><BR>
 
3253
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~&nbsp;(forall&nbsp;a&nbsp;b:X,&nbsp;~&nbsp;(forall&nbsp;x:X,&nbsp;x&nbsp;&lt;&gt;&nbsp;a&nbsp;-&gt;&nbsp;x&nbsp;&lt;&gt;&nbsp;b&nbsp;-&gt;&nbsp;False))).</TT><BR>
 
3254
<BR>
 
3255
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;intro&nbsp;Heq;&nbsp;assert&nbsp;(H:&nbsp;discr&nbsp;bool).</TT><BR>
 
3256
<BR>
 
3257
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;intro&nbsp;H;&nbsp;apply&nbsp;(H&nbsp;true&nbsp;false);&nbsp;destruct&nbsp;x;&nbsp;auto.</TT><BR>
 
3258
<BR>
 
3259
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;rewrite&nbsp;Heq&nbsp;in&nbsp;H;&nbsp;apply&nbsp;H;&nbsp;clear&nbsp;H.</TT><BR>
 
3260
<BR>
 
3261
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;destruct&nbsp;a;&nbsp;destruct&nbsp;b&nbsp;as&nbsp;[|n];&nbsp;intro&nbsp;H0;&nbsp;eauto.</TT><BR>
 
3262
<BR>
 
3263
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;destruct&nbsp;n;&nbsp;[&nbsp;apply&nbsp;(H0&nbsp;2);&nbsp;discriminate&nbsp;|&nbsp;eauto&nbsp;].</TT><BR>
 
3264
<BR>
 
3265
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3266
</DIV>
 
3267
<BR>
 
3268
<!--TOC subsubsection Is there an axiom-free proof of Streicher's axiom <I>K</I> for
 
3269
the equality on <TT>nat</TT>?-->
 
3270
 
 
3271
<H4><A NAME="htoc156">135</A>&nbsp;&nbsp;Is there an axiom-free proof of Streicher's axiom <I>K</I> for
 
3272
the equality on <TT>nat</TT>?</H4><!--SEC END -->
 
3273
 
 
3274
<A NAME="K-nat"></A>
 
3275
Yes, because equality is decidable on <TT>nat</TT>. Here is the proof.<BR>
 
3276
<BR>
 
3277
 
 
3278
<DIV ALIGN=left>
 
3279
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;Eqdep_dec.</TT><BR>
 
3280
<BR>
 
3281
<TT>Coq&nbsp;&lt;&nbsp;Require&nbsp;Import&nbsp;Peano_dec.</TT><BR>
 
3282
<BR>
 
3283
<TT>Coq&nbsp;&lt;&nbsp;Theorem&nbsp;K_nat&nbsp;:</TT><BR>
 
3284
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;(x:nat)&nbsp;(P:x&nbsp;=&nbsp;x&nbsp;-&gt;&nbsp;Prop),&nbsp;P&nbsp;(refl_equal&nbsp;x)&nbsp;-&gt;&nbsp;forall&nbsp;p:x&nbsp;=&nbsp;x,&nbsp;P&nbsp;p.</TT><BR>
 
3285
<BR>
 
3286
<TT>Coq&nbsp;&lt;&nbsp;Proof.</TT><BR>
 
3287
<BR>
 
3288
<TT>Coq&nbsp;&lt;&nbsp;intros;&nbsp;apply&nbsp;K_dec_set&nbsp;with&nbsp;(p&nbsp;:=&nbsp;p).</TT><BR>
 
3289
<BR>
 
3290
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;eq_nat_dec.</TT><BR>
 
3291
<BR>
 
3292
<TT>Coq&nbsp;&lt;&nbsp;assumption.</TT><BR>
 
3293
<BR>
 
3294
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3295
</DIV>
 
3296
<BR>
 
3297
Similarly, we have<BR>
 
3298
<BR>
 
3299
 
 
3300
<DIV ALIGN=left>
 
3301
<TT>Coq&nbsp;&lt;&nbsp;Theorem&nbsp;eq_rect_eq_nat&nbsp;:</TT><BR>
 
3302
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;(p:nat)&nbsp;(Q:nat-&gt;Type)&nbsp;(x:Q&nbsp;p)&nbsp;(h:p=p),&nbsp;x&nbsp;=&nbsp;eq_rect&nbsp;p&nbsp;Q&nbsp;x&nbsp;p&nbsp;h.</TT><BR>
 
3303
<BR>
 
3304
<TT>Coq&nbsp;&lt;&nbsp;Proof.</TT><BR>
 
3305
<BR>
 
3306
<TT>Coq&nbsp;&lt;&nbsp;intros;&nbsp;apply&nbsp;K_nat&nbsp;with&nbsp;(p&nbsp;:=&nbsp;h);&nbsp;reflexivity.</TT><BR>
 
3307
<BR>
 
3308
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3309
</DIV>
 
3310
<BR>
 
3311
<!--TOC subsubsection How to prove that two proofs of <TT>n&lt;=m</TT> on <TT>nat</TT> are equal?-->
 
3312
 
 
3313
<H4><A NAME="htoc157">136</A>&nbsp;&nbsp;How to prove that two proofs of <TT>n&lt;=m</TT> on <TT>nat</TT> are equal?</H4><!--SEC END -->
 
3314
 
 
3315
<A NAME="le-uniqueness"></A>
 
3316
This is provable without requiring any axiom because axiom <I>K</I>
 
3317
directly holds on <TT>nat</TT>. Here is a proof using question <A HREF="#K-nat">135</A>.<BR>
 
3318
<BR>
 
3319
 
 
3320
<DIV ALIGN=left>
 
3321
<TT>Coq&nbsp;&lt;&nbsp;Scheme&nbsp;le_ind'&nbsp;:=&nbsp;Induction&nbsp;for&nbsp;le&nbsp;Sort&nbsp;Prop.</TT><BR>
 
3322
<BR>
 
3323
<TT>Coq&nbsp;&lt;&nbsp;Theorem&nbsp;le_uniqueness_proof&nbsp;:&nbsp;forall&nbsp;(n&nbsp;m&nbsp;:&nbsp;nat)&nbsp;(p&nbsp;q&nbsp;:&nbsp;n&nbsp;&lt;=&nbsp;m),&nbsp;p&nbsp;=&nbsp;q.</TT><BR>
 
3324
<BR>
 
3325
<TT>Coq&nbsp;&lt;&nbsp;Proof.</TT><BR>
 
3326
<BR>
 
3327
<TT>Coq&nbsp;&lt;&nbsp;induction&nbsp;p&nbsp;using&nbsp;le_ind';&nbsp;intro&nbsp;q.</TT><BR>
 
3328
<BR>
 
3329
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;replace&nbsp;(le_n&nbsp;n)&nbsp;with</TT><BR>
 
3330
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;(eq_rect&nbsp;_&nbsp;(fun&nbsp;n0&nbsp;=&gt;&nbsp;n&nbsp;&lt;=&nbsp;n0)&nbsp;(le_n&nbsp;n)&nbsp;_&nbsp;(refl_equal&nbsp;n)).</TT><BR>
 
3331
<BR>
 
3332
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;2:reflexivity.</TT><BR>
 
3333
<BR>
 
3334
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;generalize&nbsp;(refl_equal&nbsp;n).</TT><BR>
 
3335
<BR>
 
3336
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pattern&nbsp;n&nbsp;at&nbsp;2&nbsp;4&nbsp;6&nbsp;10,&nbsp;q;&nbsp;case&nbsp;q;&nbsp;[intro&nbsp;|&nbsp;intros&nbsp;m&nbsp;l&nbsp;e].</TT><BR>
 
3337
<BR>
 
3338
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite&nbsp;&lt;-&nbsp;eq_rect_eq_nat;&nbsp;trivial.</TT><BR>
 
3339
<BR>
 
3340
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contradiction&nbsp;(le_Sn_n&nbsp;m);&nbsp;rewrite&nbsp;&lt;-&nbsp;e;&nbsp;assumption.</TT><BR>
 
3341
<BR>
 
3342
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;replace&nbsp;(le_S&nbsp;n&nbsp;m&nbsp;p)&nbsp;with</TT><BR>
 
3343
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;(eq_rect&nbsp;_&nbsp;(fun&nbsp;n0&nbsp;=&gt;&nbsp;n&nbsp;&lt;=&nbsp;n0)&nbsp;(le_S&nbsp;n&nbsp;m&nbsp;p)&nbsp;_&nbsp;(refl_equal&nbsp;(S&nbsp;m))).</TT><BR>
 
3344
<BR>
 
3345
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;2:reflexivity.</TT><BR>
 
3346
<BR>
 
3347
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;generalize&nbsp;(refl_equal&nbsp;(S&nbsp;m)).</TT><BR>
 
3348
<BR>
 
3349
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pattern&nbsp;(S&nbsp;m)&nbsp;at&nbsp;1&nbsp;3&nbsp;4&nbsp;6,&nbsp;q;&nbsp;case&nbsp;q;&nbsp;[intro&nbsp;Heq&nbsp;|&nbsp;intros&nbsp;m0&nbsp;l&nbsp;HeqS].</TT><BR>
 
3350
<BR>
 
3351
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contradiction&nbsp;(le_Sn_n&nbsp;m);&nbsp;rewrite&nbsp;Heq;&nbsp;assumption.</TT><BR>
 
3352
<BR>
 
3353
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;injection&nbsp;HeqS;&nbsp;intro&nbsp;Heq;&nbsp;generalize&nbsp;l&nbsp;HeqS.</TT><BR>
 
3354
<BR>
 
3355
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite&nbsp;&lt;-&nbsp;Heq;&nbsp;intros;&nbsp;rewrite&nbsp;&lt;-&nbsp;eq_rect_eq_nat.</TT><BR>
 
3356
<BR>
 
3357
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite&nbsp;(IHp&nbsp;l0);&nbsp;reflexivity.</TT><BR>
 
3358
<BR>
 
3359
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3360
</DIV>
 
3361
<BR>
 
3362
<!--TOC subsubsection How to exploit equalities on sets-->
 
3363
 
 
3364
<H4><A NAME="htoc158">137</A>&nbsp;&nbsp;How to exploit equalities on sets</H4><!--SEC END -->
 
3365
 
 
3366
To extract information from an equality on sets, you need to
 
3367
find a predicate of sets satisfied by the elements of the sets. As an
 
3368
example, let's consider the following theorem.<BR>
 
3369
<BR>
 
3370
 
 
3371
<DIV ALIGN=left>
 
3372
<TT>Coq&nbsp;&lt;&nbsp;Theorem&nbsp;interval_discr&nbsp;:</TT><BR>
 
3373
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;m&nbsp;n:nat,</TT><BR>
 
3374
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{x&nbsp;:&nbsp;nat&nbsp;|&nbsp;x&nbsp;&lt;=&nbsp;m}&nbsp;=&nbsp;{x&nbsp;:&nbsp;nat&nbsp;|&nbsp;x&nbsp;&lt;=&nbsp;n}&nbsp;-&gt;&nbsp;m&nbsp;=&nbsp;n.</TT><BR>
 
3375
</DIV>
 
3376
<BR>
 
3377
We have a proof requiring the axiom of proof-irrelevance. We
 
3378
conjecture that proof-irrelevance can be circumvented by introducing a
 
3379
primitive definition of discrimination of the proofs of
 
3380
<CODE>{x : nat | x &lt;= m}</CODE>.<BR>
 
3381
<BR>
 
3382
<A HREF="./interval_discr.v">Here</A> is the proof.
 
3383
<BR>
 
3384
<BR>
 
3385
<!--TOC subsubsection I have a problem of dependent elimination on
 
3386
proofs, how to solve it?-->
 
3387
 
 
3388
<H4><A NAME="htoc159">138</A>&nbsp;&nbsp;I have a problem of dependent elimination on
 
3389
proofs, how to solve it?</H4><!--SEC END -->
 
3390
 
 
3391
 
 
3392
<DIV ALIGN=left>
 
3393
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;Def1&nbsp;:&nbsp;Set&nbsp;:=&nbsp;c1&nbsp;:&nbsp;Def1.</TT><BR>
 
3394
<BR>
 
3395
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;DefProp&nbsp;:&nbsp;Def1&nbsp;-&gt;&nbsp;Prop&nbsp;:=</TT><BR>
 
3396
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;c2&nbsp;:&nbsp;forall&nbsp;d:Def1,&nbsp;DefProp&nbsp;d.</TT><BR>
 
3397
<BR>
 
3398
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;Comb&nbsp;:&nbsp;Set&nbsp;:=</TT><BR>
 
3399
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;c3&nbsp;:&nbsp;forall&nbsp;d:Def1,&nbsp;DefProp&nbsp;d&nbsp;-&gt;&nbsp;Comb.</TT><BR>
 
3400
<BR>
 
3401
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;eq_comb&nbsp;:</TT><BR>
 
3402
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;(d1&nbsp;d1':Def1)&nbsp;(d2:DefProp&nbsp;d1)&nbsp;(d2':DefProp&nbsp;d1'),</TT><BR>
 
3403
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d1&nbsp;=&nbsp;d1'&nbsp;-&gt;&nbsp;c3&nbsp;d1&nbsp;d2&nbsp;=&nbsp;c3&nbsp;d1'&nbsp;d2'.</TT><BR>
 
3404
</DIV>
 
3405
<BR>
 
3406
You need to derive the dependent elimination
 
3407
scheme for DefProp by hand using <TT>S</TT>cheme.<BR>
 
3408
<BR>
 
3409
 
 
3410
<DIV ALIGN=left>
 
3411
<TT>Coq&nbsp;&lt;&nbsp;Scheme&nbsp;DefProp_elim&nbsp;:=&nbsp;Induction&nbsp;for&nbsp;DefProp&nbsp;Sort&nbsp;Prop.</TT><BR>
 
3412
<BR>
 
3413
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;eq_comb&nbsp;:</TT><BR>
 
3414
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;d1&nbsp;d1':Def1,</TT><BR>
 
3415
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d1&nbsp;=&nbsp;d1'&nbsp;-&gt;</TT><BR>
 
3416
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;(d2:DefProp&nbsp;d1)&nbsp;(d2':DefProp&nbsp;d1'),&nbsp;c3&nbsp;d1&nbsp;d2&nbsp;=&nbsp;c3&nbsp;d1'&nbsp;d2'.</TT><BR>
 
3417
<BR>
 
3418
<TT>Coq&nbsp;&lt;&nbsp;intros.</TT><BR>
 
3419
<BR>
 
3420
<TT>Coq&nbsp;&lt;&nbsp;destruct&nbsp;H.</TT><BR>
 
3421
<BR>
 
3422
<TT>Coq&nbsp;&lt;&nbsp;destruct&nbsp;d2&nbsp;using&nbsp;DefProp_elim.</TT><BR>
 
3423
<BR>
 
3424
<TT>Coq&nbsp;&lt;&nbsp;destruct&nbsp;d2'&nbsp;using&nbsp;DefProp_elim.</TT><BR>
 
3425
<BR>
 
3426
<TT>Coq&nbsp;&lt;&nbsp;reflexivity.</TT><BR>
 
3427
<BR>
 
3428
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3429
</DIV>
 
3430
<BR>
 
3431
<!--TOC subsubsection And what if I want to prove the following?-->
 
3432
 
 
3433
<H4><A NAME="htoc160">139</A>&nbsp;&nbsp;And what if I want to prove the following?</H4><!--SEC END -->
 
3434
 
 
3435
 
 
3436
<DIV ALIGN=left>
 
3437
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;natProp&nbsp;:&nbsp;nat&nbsp;-&gt;&nbsp;Prop&nbsp;:=</TT><BR>
 
3438
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;p0&nbsp;:&nbsp;natProp&nbsp;0</TT><BR>
 
3439
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;|&nbsp;pS&nbsp;:&nbsp;forall&nbsp;n:nat,&nbsp;natProp&nbsp;n&nbsp;-&gt;&nbsp;natProp&nbsp;(S&nbsp;n).</TT><BR>
 
3440
<BR>
 
3441
<TT>Coq&nbsp;&lt;&nbsp;Inductive&nbsp;package&nbsp;:&nbsp;Set&nbsp;:=</TT><BR>
 
3442
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;pack&nbsp;:&nbsp;forall&nbsp;n:nat,&nbsp;natProp&nbsp;n&nbsp;-&gt;&nbsp;package.</TT><BR>
 
3443
<BR>
 
3444
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;eq_pack&nbsp;:</TT><BR>
 
3445
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;forall&nbsp;n&nbsp;n':nat,</TT><BR>
 
3446
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;=&nbsp;n'&nbsp;-&gt;</TT><BR>
 
3447
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;(np:natProp&nbsp;n)&nbsp;(np':natProp&nbsp;n'),&nbsp;pack&nbsp;n&nbsp;np&nbsp;=&nbsp;pack&nbsp;n'&nbsp;np'.</TT><BR>
 
3448
</DIV>
 
3449
<BR>
 
3450
 
 
3451
<DIV ALIGN=left>
 
3452
<TT>Coq&nbsp;&lt;&nbsp;Scheme&nbsp;natProp_elim&nbsp;:=&nbsp;Induction&nbsp;for&nbsp;natProp&nbsp;Sort&nbsp;Prop.</TT><BR>
 
3453
<BR>
 
3454
<TT>Coq&nbsp;&lt;&nbsp;Definition&nbsp;pack_S&nbsp;:&nbsp;package&nbsp;-&gt;&nbsp;package.</TT><BR>
 
3455
<BR>
 
3456
<TT>Coq&nbsp;&lt;&nbsp;destruct&nbsp;1.</TT><BR>
 
3457
<BR>
 
3458
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;(pack&nbsp;(S&nbsp;n)).</TT><BR>
 
3459
<BR>
 
3460
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;pS;&nbsp;assumption.</TT><BR>
 
3461
<BR>
 
3462
<TT>Coq&nbsp;&lt;&nbsp;Defined.</TT><BR>
 
3463
<BR>
 
3464
<TT>Coq&nbsp;&lt;&nbsp;Lemma&nbsp;eq_pack&nbsp;:</TT><BR>
 
3465
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;forall&nbsp;n&nbsp;n':nat,</TT><BR>
 
3466
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;=&nbsp;n'&nbsp;-&gt;</TT><BR>
 
3467
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forall&nbsp;(np:natProp&nbsp;n)&nbsp;(np':natProp&nbsp;n'),&nbsp;pack&nbsp;n&nbsp;np&nbsp;=&nbsp;pack&nbsp;n'&nbsp;np'.</TT><BR>
 
3468
<BR>
 
3469
<TT>Coq&nbsp;&lt;&nbsp;intros&nbsp;n&nbsp;n'&nbsp;Heq&nbsp;np&nbsp;np'.</TT><BR>
 
3470
<BR>
 
3471
<TT>Coq&nbsp;&lt;&nbsp;generalize&nbsp;dependent&nbsp;n'.</TT><BR>
 
3472
<BR>
 
3473
<TT>Coq&nbsp;&lt;&nbsp;induction&nbsp;np&nbsp;using&nbsp;natProp_elim.</TT><BR>
 
3474
<BR>
 
3475
<TT>Coq&nbsp;&lt;&nbsp;induction&nbsp;np'&nbsp;using&nbsp;natProp_elim;&nbsp;intros;&nbsp;auto.</TT><BR>
 
3476
<BR>
 
3477
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;discriminate&nbsp;Heq.</TT><BR>
 
3478
<BR>
 
3479
<TT>Coq&nbsp;&lt;&nbsp;induction&nbsp;np'&nbsp;using&nbsp;natProp_elim;&nbsp;intros;&nbsp;auto.</TT><BR>
 
3480
<BR>
 
3481
<TT>Coq&nbsp;&lt;&nbsp;&nbsp;discriminate&nbsp;Heq.</TT><BR>
 
3482
<BR>
 
3483
<TT>Coq&nbsp;&lt;&nbsp;change&nbsp;(pack_S&nbsp;(pack&nbsp;n&nbsp;np)&nbsp;=&nbsp;pack_S&nbsp;(pack&nbsp;n0&nbsp;np')).</TT><BR>
 
3484
<BR>
 
3485
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;(f_equal&nbsp;(A:=package)).</TT><BR>
 
3486
<BR>
 
3487
<TT>Coq&nbsp;&lt;&nbsp;apply&nbsp;IHnp.</TT><BR>
 
3488
<BR>
 
3489
<TT>Coq&nbsp;&lt;&nbsp;auto.</TT><BR>
 
3490
<BR>
 
3491
<TT>Coq&nbsp;&lt;&nbsp;Qed.</TT><BR>
 
3492
</DIV>
 
3493
<BR>
 
3494
<!--TOC section Publishing tools-->
 
3495
 
 
3496
<H2><A NAME="htoc161">13</A>&nbsp;&nbsp;Publishing tools</H2><!--SEC END -->
 
3497
 
 
3498
<!--TOC subsubsection How can I generate some latex from my development?-->
 
3499
 
 
3500
<H4><A NAME="htoc162">140</A>&nbsp;&nbsp;How can I generate some latex from my development?</H4><!--SEC END -->
 
3501
 
 
3502
You can use <TT>coqdoc</TT>.<BR>
 
3503
<BR>
 
3504
<!--TOC subsubsection How can I generate some HTML from my development?-->
 
3505
 
 
3506
<H4><A NAME="htoc163">141</A>&nbsp;&nbsp;How can I generate some HTML from my development?</H4><!--SEC END -->
 
3507
 
 
3508
You can use <TT>coqdoc</TT>.<BR>
 
3509
<BR>
 
3510
<!--TOC subsubsection How can I generate some dependency graph from my development?-->
 
3511
 
 
3512
<H4><A NAME="htoc164">142</A>&nbsp;&nbsp;How can I generate some dependency graph from my development?</H4><!--SEC END -->
 
3513
 
 
3514
<!--TOC subsubsection How can I cite some <FONT COLOR=navy>Coq</FONT> in my latex document?-->
 
3515
 
 
3516
<H4><A NAME="htoc165">143</A>&nbsp;&nbsp;How can I cite some <FONT COLOR=navy>Coq</FONT> in my latex document?</H4><!--SEC END -->
 
3517
 
 
3518
You can use <TT>coq_tex</TT>.<BR>
 
3519
<BR>
 
3520
<!--TOC subsubsection How can I cite the <FONT COLOR=navy>Coq</FONT> reference manual?-->
 
3521
 
 
3522
<H4><A NAME="htoc166">144</A>&nbsp;&nbsp;How can I cite the <FONT COLOR=navy>Coq</FONT> reference manual?</H4><!--SEC END -->
 
3523
 
 
3524
You can use this bibtex entry:
 
3525
<PRE>
 
3526
@Manual{Coq:manual,
 
3527
  title =        {The Coq proof assistant reference manual},
 
3528
  author =       {\mbox{The Coq development team}},
 
3529
  organization = {LogiCal Project},
 
3530
  note =         {Version 8.0},
 
3531
  year =         {2004},
 
3532
  url =          "http://coq.inria.fr"
 
3533
}
 
3534
</PRE>
 
3535
<!--TOC subsubsection Where can I publish my developments in <FONT COLOR=navy>Coq</FONT>?-->
 
3536
 
 
3537
<H4><A NAME="htoc167">145</A>&nbsp;&nbsp;Where can I publish my developments in <FONT COLOR=navy>Coq</FONT>?</H4><!--SEC END -->
 
3538
 
 
3539
You can submit your developments as a user contribution to the <FONT COLOR=navy>Coq</FONT>
 
3540
development team. This ensures its liveness along the evolution and
 
3541
possible changes of <FONT COLOR=navy>Coq</FONT>.<BR>
 
3542
<BR>
 
3543
You can also submit your developments to the HELM/MoWGLI repository at
 
3544
the University of Bologna (see
 
3545
<A HREF="http://mowgli.cs.unibo.it"><TT>http://mowgli.cs.unibo.it</TT></A>). For
 
3546
developments submitted in this database, it is possible to visualize
 
3547
the developments in natural language and execute various retrieving
 
3548
requests.<BR>
 
3549
<BR>
 
3550
<!--TOC subsubsection How can I read my proof in natural language?-->
 
3551
 
 
3552
<H4><A NAME="htoc168">146</A>&nbsp;&nbsp;How can I read my proof in natural language?</H4><!--SEC END -->
 
3553
 
 
3554
You can submit your proof to the HELM/MoWGLI repository and use the
 
3555
rendering tool provided by the server (see
 
3556
<A HREF="http://mowgli.cs.unibo.it"><TT>http://mowgli.cs.unibo.it</TT></A>).<BR>
 
3557
<BR>
 
3558
<!--TOC section <FONT COLOR=navy>CoqIde</FONT>-->
 
3559
 
 
3560
<H2><A NAME="htoc169">14</A>&nbsp;&nbsp;<FONT COLOR=navy>CoqIde</FONT></H2><!--SEC END -->
 
3561
 
 
3562
<!--TOC subsubsection What is <FONT COLOR=navy>CoqIde</FONT>?-->
 
3563
 
 
3564
<H4><A NAME="htoc170">147</A>&nbsp;&nbsp;What is <FONT COLOR=navy>CoqIde</FONT>?</H4><!--SEC END -->
 
3565
 
 
3566
<FONT COLOR=navy>CoqIde</FONT> is a gtk based GUI for <FONT COLOR=navy>Coq</FONT>.<BR>
 
3567
<BR>
 
3568
<!--TOC subsubsection How to enable Emacs keybindings?-->
 
3569
 
 
3570
<H4><A NAME="htoc171">148</A>&nbsp;&nbsp;How to enable Emacs keybindings?</H4><!--SEC END -->
 
3571
 
 
3572
 Insert <TT>gtk-key-theme-name = "Emacs"</TT>
 
3573
 in your <TT>.coqide-gtk2rc</TT> file. It may be in the current dir
 
3574
 or in <CODE>$HOME</CODE> dir. This is done by default.<BR>
 
3575
<BR>
 
3576
<!--TOC subsubsection How to enable antialiased fonts?-->
 
3577
 
 
3578
<H4><A NAME="htoc172">149</A>&nbsp;&nbsp;How to enable antialiased fonts?</H4><!--SEC END -->
 
3579
 
 
3580
Set the <CODE>GDK_USE_XFT</CODE> variable to <CODE>1</CODE>. This is by default with <CODE>Gtk &gt;= 2.2</CODE>.
 
3581
 If some of your fonts are not available, set <CODE>GDK_USE_XFT</CODE> to <CODE>0</CODE>.<BR>
 
3582
<BR>
 
3583
<!--TOC subsubsection How to use those Forall and Exists pretty symbols?-->
 
3584
 
 
3585
<H4><A NAME="htoc173">150</A>&nbsp;&nbsp;How to use those Forall and Exists pretty symbols?</H4><!--SEC END -->
 
3586
<A NAME="forallcoqide"></A>
 
3587
 Thanks to the notation features in <FONT COLOR=navy>Coq</FONT>, you just need to insert these
 
3588
lines in your <FONT COLOR=navy>Coq</FONT> buffer:<BR>
 
3589
<TT>N</TT>otation "for all x : t, P" := (forall x:t, P) (at level 200, x ident).
 
3590
<BR>
 
3591
<TT>N</TT>otation "there exists x : t, P" := (exists x:t, P) (at level 200, x ident).
 
3592
<BR>
 
3593
<BR>
 
3594
Copy/Paste of these lines from this file will not work outside of <FONT COLOR=navy>CoqIde</FONT>.
 
3595
You need to load a file containing these lines or to enter the for all
 
3596
using an input method (see <A HREF="#inputmeth">151</A>). To try it just use <CODE>Require Import utf8</CODE> from inside
 
3597
<FONT COLOR=navy>CoqIde</FONT>. 
 
3598
To enable these notations automatically start coqide with
 
3599
<PRE>
 
3600
 coqide -l utf8
 
3601
</PRE>In the ide subdir of <FONT COLOR=navy>Coq</FONT> library, you will find a sample utf8.v with some 
 
3602
pretty simple notations.<BR>
 
3603
<BR>
 
3604
<!--TOC subsubsection How to define an input method for non ASCII symbols?-->
 
3605
 
 
3606
<H4><A NAME="htoc174">151</A>&nbsp;&nbsp;How to define an input method for non ASCII symbols?</H4><!--SEC END -->
 
3607
<A NAME="inputmeth"></A>
 
3608
<UL><LI>
 
3609
First solution: type <CODE>&lt;CONTROL&gt;&lt;SHIFT&gt;2200</CODE> to enter a forall in the script widow. 
 
3610
        2200 is the hexadecimal code for forall in unicode charts and is encoded as     
 
3611
        in UTF-8.
 
3612
        2203 is for exists. See <A HREF="http://www.unicode.org"><TT>http://www.unicode.org</TT></A> for more codes.
 
3613
<LI>Second solution: rebind <CODE>&lt;AltGr&gt;a</CODE> to forall and <CODE>&lt;AltGr&gt;e</CODE> to exists. 
 
3614
        Under X11, you need to use something like
 
3615
<PRE>
 
3616
  xmodmap -e "keycode  24 = a A F13 F13" 
 
3617
  xmodmap -e "keycode  26 = e E F14 F14"
 
3618
</PRE>  and then to add 
 
3619
<PRE>
 
3620
  bind "F13" {"insert-at-cursor" ("")}
 
3621
  bind "F14" {"insert-at-cursor" ("")}
 
3622
</PRE>  to your "binding "text"" section in <CODE>.coqiderc-gtk2rc.</CODE>
 
3623
        The strange ("") argument is the UTF-8 encoding for
 
3624
        0x2200. 
 
3625
        You can compute these encodings using the lablgtk2 toplevel with 
 
3626
<PRE>  
 
3627
Glib.Utf8.from_unichar 0x2200;;
 
3628
</PRE>  Further symbols can be bound on higher Fxx keys or on even on other keys you
 
3629
        do not need .
 
3630
</UL>
 
3631
<!--TOC subsubsection How to build a custom <FONT COLOR=navy>CoqIde</FONT> with user ml code?-->
 
3632
 
 
3633
<H4><A NAME="htoc175">152</A>&nbsp;&nbsp;How to build a custom <FONT COLOR=navy>CoqIde</FONT> with user ml code?</H4><!--SEC END -->
 
3634
 
 
3635
 Use 
 
3636
        coqmktop -ide -byte m1.cmo...mi.cmo
 
3637
 or 
 
3638
        coqmktop -ide -opt m1.cmx...mi.cmx<BR>
 
3639
<BR>
 
3640
<!--TOC subsubsection How to customize the shortcuts for menus?-->
 
3641
 
 
3642
<H4><A NAME="htoc176">153</A>&nbsp;&nbsp;How to customize the shortcuts for menus?</H4><!--SEC END -->
 
3643
 
 
3644
 Two solutions are offered:
 
3645
<UL><LI>
 
3646
Edit $HOME/.coqide.keys by hand or
 
3647
<LI>Add "gtk-can-change-accels = 1" in your .coqide-gtk2rc file. Then
 
3648
 from <FONT COLOR=navy>CoqIde</FONT>, you may select a menu entry and press the desired 
 
3649
 shortcut. 
 
3650
</UL>
 
3651
<!--TOC subsubsection What encoding should I use? What is this \x{iiii} in my file?-->
 
3652
 
 
3653
<H4><A NAME="htoc177">154</A>&nbsp;&nbsp;What encoding should I use? What is this \x{iiii} in my file?</H4><!--SEC END -->
 
3654
 
 
3655
 The encoding option is related to the way files are saved. 
 
3656
 Keep it as UTF-8 until it becomes important for you to exchange files 
 
3657
 with non UTF-8 aware applications.
 
3658
 If you choose something else than UTF-8, then missing characters will 
 
3659
 be encoded by \x{....} or \x{........}
 
3660
 where each dot is an hex. digit. 
 
3661
 The number between braces is the hexadecimal UNICODE index for the
 
3662
 missing character.<BR>
 
3663
<BR>
 
3664
<!--TOC section Extraction-->
 
3665
 
 
3666
<H2><A NAME="htoc178">15</A>&nbsp;&nbsp;Extraction</H2><!--SEC END -->
 
3667
 
 
3668
<!--TOC subsubsection What is program extraction?-->
 
3669
 
 
3670
<H4><A NAME="htoc179">155</A>&nbsp;&nbsp;What is program extraction?</H4><!--SEC END -->
 
3671
 
 
3672
Program extraction consist in generating a program from a constructive proof.<BR>
 
3673
<BR>
 
3674
<!--TOC subsubsection Which language can I extract to?-->
 
3675
 
 
3676
<H4><A NAME="htoc180">156</A>&nbsp;&nbsp;Which language can I extract to?</H4><!--SEC END -->
 
3677
 
 
3678
You can extract your programs to Objective Caml and Haskell.<BR>
 
3679
<BR>
 
3680
<!--TOC subsubsection How can I extract an incomplete proof?-->
 
3681
 
 
3682
<H4><A NAME="htoc181">157</A>&nbsp;&nbsp;How can I extract an incomplete proof?</H4><!--SEC END -->
 
3683
 
 
3684
You can provide programs for your axioms.<BR>
 
3685
<BR>
 
3686
<!--TOC section Glossary-->
 
3687
 
 
3688
<H2><A NAME="htoc182">16</A>&nbsp;&nbsp;Glossary</H2><!--SEC END -->
 
3689
 
 
3690
<!--TOC subsubsection Can you explain me what an evaluable constant is?-->
 
3691
 
 
3692
<H4><A NAME="htoc183">158</A>&nbsp;&nbsp;Can you explain me what an evaluable constant is?</H4><!--SEC END -->
 
3693
 
 
3694
An evaluable constant is a constant which is unfoldable.<BR>
 
3695
<BR>
 
3696
<!--TOC subsubsection What is a goal?-->
 
3697
 
 
3698
<H4><A NAME="htoc184">159</A>&nbsp;&nbsp;What is a goal?</H4><!--SEC END -->
 
3699
 
 
3700
The goal is the statement to be proved.<BR>
 
3701
<BR>
 
3702
<!--TOC subsubsection What is a meta variable?-->
 
3703
 
 
3704
<H4><A NAME="htoc185">160</A>&nbsp;&nbsp;What is a meta variable?</H4><!--SEC END -->
 
3705
 
 
3706
A meta variable in <FONT COLOR=navy>Coq</FONT> represents a ``hole'', i.e. a part of a proof
 
3707
that is still unknown. <BR>
 
3708
<BR>
 
3709
<!--TOC subsubsection What is Gallina?-->
 
3710
 
 
3711
<H4><A NAME="htoc186">161</A>&nbsp;&nbsp;What is Gallina?</H4><!--SEC END -->
 
3712
 
 
3713
Gallina is the specification language of <FONT COLOR=navy>Coq</FONT>. Complete documentation
 
3714
of this language can be found in the Reference Manual.<BR>
 
3715
<BR>
 
3716
<!--TOC subsubsection What is The Vernacular?-->
 
3717
 
 
3718
<H4><A NAME="htoc187">162</A>&nbsp;&nbsp;What is The Vernacular?</H4><!--SEC END -->
 
3719
 
 
3720
It is the language of commands of Gallina i.e. definitions, lemmas, ... <BR>
 
3721
<BR>
 
3722
<!--TOC subsubsection What is a dependent type?-->
 
3723
 
 
3724
<H4><A NAME="htoc188">163</A>&nbsp;&nbsp;What is a dependent type?</H4><!--SEC END -->
 
3725
 
 
3726
A dependant type is a type which depends on some term. For instance
 
3727
``vector of size n'' is a dependant type representing all the vectors
 
3728
of size <I>n</I>. Its type depends on <I>n</I><BR>
 
3729
<BR>
 
3730
<!--TOC subsubsection What is a proof by reflection?-->
 
3731
 
 
3732
<H4><A NAME="htoc189">164</A>&nbsp;&nbsp;What is a proof by reflection?</H4><!--SEC END -->
 
3733
 
 
3734
This is a proof generated by some computation which is done using the
 
3735
internal reduction of <FONT COLOR=navy>Coq</FONT> (not using the tactic language of <FONT COLOR=navy>Coq</FONT>
 
3736
(<FONT COLOR=navy>Ltac</FONT>) nor the implementation language for <FONT COLOR=navy>Coq</FONT>). An example of
 
3737
tactic using the reflection mechanism is the <TT>ring</TT> tactic. The
 
3738
reflection method consist in reflecting a subset of <FONT COLOR=navy>Coq</FONT> language (for
 
3739
example the arithmetical expressions) into an object of the <FONT COLOR=navy>Coq</FONT>language itself (in this case an inductive type denoting arithmetical
 
3740
expressions). For more information see&nbsp;[<A HREF="#howe"><CITE>13</CITE></A><CITE>, </CITE><A HREF="#harrison"><CITE>11</CITE></A><CITE>, </CITE><A HREF="#boutin"><CITE>2</CITE></A>]
 
3741
and the last chapter of the Coq'Art.<BR>
 
3742
<BR>
 
3743
<!--TOC subsubsection What is intuitionistic logic?-->
 
3744
 
 
3745
<H4><A NAME="htoc190">165</A>&nbsp;&nbsp;What is intuitionistic logic?</H4><!--SEC END -->
 
3746
 
 
3747
This is any logic which does not assume that ``A or not A''.<BR>
 
3748
<BR>
 
3749
<!--TOC subsubsection What is proof-irrelevance?-->
 
3750
 
 
3751
<H4><A NAME="htoc191">166</A>&nbsp;&nbsp;What is proof-irrelevance?</H4><!--SEC END -->
 
3752
 
 
3753
See question <A HREF="#proof-irrelevance">34</A><BR>
 
3754
<BR>
 
3755
<!--TOC subsubsection What is the difference between opaque and transparent?-->
 
3756
 
 
3757
<H4><A NAME="htoc192">167</A>&nbsp;&nbsp;What is the difference between opaque and transparent?</H4><!--SEC END -->
 
3758
<A NAME="opaque"></A>   <BR>
 
3759
<BR>
 
3760
Opaque definitions can not be unfolded but transparent ones can.<BR>
 
3761
<BR>
 
3762
<!--TOC section Troubleshooting-->
 
3763
 
 
3764
<H2><A NAME="htoc193">17</A>&nbsp;&nbsp;Troubleshooting</H2><!--SEC END -->
 
3765
 
 
3766
<!--TOC subsubsection What can I do when <TT>Qed.</TT> is slow?-->
 
3767
 
 
3768
<H4><A NAME="htoc194">168</A>&nbsp;&nbsp;What can I do when <TT>Qed.</TT> is slow?</H4><!--SEC END -->
 
3769
 
 
3770
Sometime you can use the <TT>abstract</TT> tactic, which makes as if you had
 
3771
stated some local lemma, this speeds up the typing process.<BR>
 
3772
<BR>
 
3773
<!--TOC subsubsection Why <TT>Reset Initial.</TT> does not work when using <TT>coqc</TT>?-->
 
3774
 
 
3775
<H4><A NAME="htoc195">169</A>&nbsp;&nbsp;Why <TT>Reset Initial.</TT> does not work when using <TT>coqc</TT>?</H4><!--SEC END -->
 
3776
 
 
3777
The initial state corresponds to the state of coqtop when the interactive
 
3778
session began. It does not make sense in files to compile.<BR>
 
3779
<BR>
 
3780
<!--TOC subsubsection What can I do if I get ``No more subgoals but non-instantiated existential variables''?-->
 
3781
 
 
3782
<H4><A NAME="htoc196">170</A>&nbsp;&nbsp;What can I do if I get ``No more subgoals but non-instantiated existential variables''?</H4><!--SEC END -->
 
3783
 
 
3784
This means that <TT>eauto</TT> or <TT>eapply</TT> didn't instantiate an
 
3785
existential variable which eventually got erased by some computation.
 
3786
You have to backtrack to the faulty occurrence of <TT>eauto</TT> or
 
3787
<TT>eapply</TT> and give the missing argument an explicit value.<BR>
 
3788
<BR>
 
3789
<!--TOC subsubsection What can I do if I get ``Cannot solve a second-order unification problem''?-->
 
3790
 
 
3791
<H4><A NAME="htoc197">171</A>&nbsp;&nbsp;What can I do if I get ``Cannot solve a second-order unification problem''?</H4><!--SEC END -->
 
3792
 
 
3793
You can help <FONT COLOR=navy>Coq</FONT> using the <TT>pattern</TT> tactic.<BR>
 
3794
<BR>
 
3795
<!--TOC subsubsection Why does <FONT COLOR=navy>Coq</FONT> tell me that <TT>{x:A|(P x)}</TT> is not convertible with <TT>(sig A P)</TT>?-->
 
3796
 
 
3797
<H4><A NAME="htoc198">172</A>&nbsp;&nbsp;Why does <FONT COLOR=navy>Coq</FONT> tell me that <TT>{x:A|(P x)}</TT> is not convertible with <TT>(sig A P)</TT>?</H4><!--SEC END -->
 
3798
 
 
3799
This is because <TT>{x:A|P x}</TT> is a notation for
 
3800
<TT>sig (fun x:A =&gt; P x)</TT>. Since <FONT COLOR=navy>Coq</FONT> does not reason up to
 
3801
eta-conversion, this is different from <TT>sig P</TT>.<BR>
 
3802
<BR>
 
3803
<!--TOC subsubsection I copy-paste a term and <FONT COLOR=navy>Coq</FONT> says it is not convertible
 
3804
 to the original term. Sometimes it even says the copied term is not
 
3805
well-typed.-->
 
3806
 
 
3807
<H4><A NAME="htoc199">173</A>&nbsp;&nbsp;I copy-paste a term and <FONT COLOR=navy>Coq</FONT> says it is not convertible
 
3808
 to the original term. Sometimes it even says the copied term is not
 
3809
well-typed.</H4><!--SEC END -->
 
3810
 
 
3811
This is probably due to invisible implicit information (implicit
 
3812
arguments, coercions and Cases annotations) in the printed term, which
 
3813
is not re-synthesised from the copied-pasted term in the same way as
 
3814
it is in the original term.<BR>
 
3815
<BR>
 
3816
Consider for instance <TT>(@eq Type True True)</TT>. This term is
 
3817
printed as <TT>True=True</TT> and re-parsed as <TT>(@eq Prop True
 
3818
True)</TT>. The two terms are not convertible (hence they fool tactics
 
3819
like <TT>pattern</TT>).<BR>
 
3820
<BR>
 
3821
There is currently no satisfactory answer to the problem. However,
 
3822
the command <TT>Set Printing All</TT> is useful for diagnosing the
 
3823
problem.<BR>
 
3824
<BR>
 
3825
Due to coercions, one may even face type-checking errors. In some
 
3826
rare cases, the criterion to hide coercions is a bit too loose, which
 
3827
may result in a typing error message if the parser is not able to find
 
3828
again the missing coercion.<BR>
 
3829
<BR>
 
3830
<!--TOC section Conclusion and Farewell.-->
 
3831
 
 
3832
<H2><A NAME="htoc200">18</A>&nbsp;&nbsp;Conclusion and Farewell.</H2><!--SEC END -->
 
3833
 
 
3834
<A NAME="ccl"></A>
 
3835
<!--TOC subsubsection What if my question isn't answered here?-->
 
3836
 
 
3837
<H4><A NAME="htoc201">174</A>&nbsp;&nbsp;What if my question isn't answered here?</H4><!--SEC END -->
 
3838
 
 
3839
<A NAME="lastquestion"></A>
 
3840
Don't panic <CODE>:-)</CODE>. You can try the <FONT COLOR=navy>Coq</FONT> manual&nbsp;[<A HREF="#Coq:manual"><CITE>15</CITE></A>] for a technical
 
3841
description of the prover. The Coq'Art&nbsp;[<A HREF="#Coq:coqart"><CITE>1</CITE></A>] is the first
 
3842
book written on <FONT COLOR=navy>Coq</FONT> and provides a comprehensive review of the
 
3843
theorem prover as well as a number of example and exercises. Finally,
 
3844
the tutorial&nbsp;[<A HREF="#Coq:Tutorial"><CITE>14</CITE></A>] provides a smooth introduction to
 
3845
theorem proving in <FONT COLOR=navy>Coq</FONT>.<BR>
 
3846
<BR>
 
3847
 
 
3848
 
 
3849
<!--TOC section References-->
 
3850
 
 
3851
<H2>References</H2><!--SEC END -->
 
3852
<DL COMPACT=compact><DT><A NAME="Coq:coqart"><FONT COLOR=purple>[1]</FONT></A><DD>
 
3853
Yves Bertot and Pierre Cast�ran.
 
3854
<EM>Interactive Theorem Proving and Program Development, Coq'Art:
 
3855
 The Calculus of Inductive Constructions</EM>.
 
3856
Texts in Theoretical Computer Science. An EATCS series. Springer
 
3857
 Verlag, 2004.<BR>
 
3858
<BR>
 
3859
<DT><A NAME="boutin"><FONT COLOR=purple>[2]</FONT></A><DD>
 
3860
Samuel Boutin.
 
3861
Using reflection to build efficient and certified decision pro
 
3862
 cedures.
 
3863
In M.&nbsp;Abadi and T.&nbsp;Ito, editors, <EM>Proceedings of TACS'97</EM>, volume
 
3864
 1281 of <EM>LNCS</EM>. Springer-Verlag, 1997.<BR>
 
3865
<BR>
 
3866
<DT><A NAME="LaTeX:symb"><FONT COLOR=purple>[3]</FONT></A><DD>
 
3867
David Carlisle, Scott Pakin, and Alexander Holt.
 
3868
<EM>The Great, Big List of L<sup>A</sup>T<sub>E</sub>X Symbols</EM>, February 2001.<BR>
 
3869
<BR>
 
3870
<DT><A NAME="Coq85"><FONT COLOR=purple>[4]</FONT></A><DD>
 
3871
Thierry Coquand.
 
3872
<EM>Une Th�orie des Constructions</EM>.
 
3873
PhD thesis, Universit� Paris&nbsp;7, January 1985.<BR>
 
3874
<BR>
 
3875
<DT><A NAME="CoHu86"><FONT COLOR=purple>[5]</FONT></A><DD>
 
3876
Thierry Coquand and G�rard Huet.
 
3877
The Calculus of Constructions.
 
3878
<EM>Information and Computation</EM>, 76(2/3), 1988.<BR>
 
3879
<BR>
 
3880
<DT><A NAME="CoPa89"><FONT COLOR=purple>[6]</FONT></A><DD>
 
3881
Thierry Coquand and Christine Paulin-Mohring.
 
3882
Inductively defined types.
 
3883
In P.&nbsp;Martin-L�f and G.&nbsp;Mints, editors, <EM>Proceedings of
 
3884
 Colog'88</EM>, volume 417 of <EM>Lecture Notes in Computer Science</EM>.
 
3885
 Springer-Verlag, 1990.<BR>
 
3886
<BR>
 
3887
<DT><A NAME="Types:Dowek"><FONT COLOR=purple>[7]</FONT></A><DD>
 
3888
Gilles Dowek.
 
3889
Th�orie des types.
 
3890
Lecture notes, 2002.<BR>
 
3891
<BR>
 
3892
<DT><A NAME="EGThese"><FONT COLOR=purple>[8]</FONT></A><DD>
 
3893
Eduardo Gim�nez.
 
3894
<EM>Un Calcul de Constructions Infinies et son application a la
 
3895
 v�rification de syst�mes communicants</EM>.
 
3896
th�se d'universit�, Ecole Normale Sup�rieure de Lyon, December 1996.<BR>
 
3897
<BR>
 
3898
<DT><A NAME="Gir70"><FONT COLOR=purple>[9]</FONT></A><DD>
 
3899
Jean-Yves Girard.
 
3900
Une extension de l'interpr�tation de G�del � l'analyse, et
 
3901
 son application � l'�limination des coupures dans l'analyse et la
 
3902
 th�orie des types.
 
3903
In <EM>Proceedings of the 2nd Scandinavian Logic Symposium</EM>.
 
3904
 North-Holland, 1970.<BR>
 
3905
<BR>
 
3906
<DT><A NAME="ProofsTypes"><FONT COLOR=purple>[10]</FONT></A><DD>
 
3907
Jean-Yves Girard, Yves Lafont, and Paul Taylor.
 
3908
<EM>Proofs and Types</EM>.
 
3909
Cambrige Tracts in Theoretical Computer Science, Cambridge University
 
3910
 Press, 1989.<BR>
 
3911
<BR>
 
3912
<DT><A NAME="harrison"><FONT COLOR=purple>[11]</FONT></A><DD>
 
3913
John Harrison.
 
3914
Meta theory and reflection in theorem proving:a survey and cri tique.
 
3915
Technical Report CRC-053, SRI International Cambridge Computer
 
3916
 Science Research Center, 1995.<BR>
 
3917
<BR>
 
3918
<DT><A NAME="HofStr98"><FONT COLOR=purple>[12]</FONT></A><DD>
 
3919
Martin Hofmann and Thomas Streicher.
 
3920
The groupoid interpretation of type theory.
 
3921
In <EM>Proceedings of the meeting Twenty-five years of constructive
 
3922
 type theory</EM>. Oxford University Press, 1998.<BR>
 
3923
<BR>
 
3924
<DT><A NAME="howe"><FONT COLOR=purple>[13]</FONT></A><DD>
 
3925
Doug Howe.
 
3926
Computation meta theory in nuprl.
 
3927
In E.&nbsp;Lusk and R.&nbsp;Overbeek, editors, <EM>The Proceedings of the
 
3928
 Ninth International Conference of Autom ated Deduction</EM>, volume 310, pages
 
3929
 238--257. Springer-Verlag, 1988.<BR>
 
3930
<BR>
 
3931
<DT><A NAME="Coq:Tutorial"><FONT COLOR=purple>[14]</FONT></A><DD>
 
3932
G�rard Huet, Gilles Kahn, and Christine Paulin-Mohring.
 
3933
<EM>The Coq Proof Assistant A Tutorial</EM>, 2004.<BR>
 
3934
<BR>
 
3935
<DT><A NAME="Coq:manual"><FONT COLOR=purple>[15]</FONT></A><DD>
 
3936
The Coq development team.
 
3937
<EM>The Coq proof assistant reference manual</EM>.
 
3938
LogiCal Project, 2004.
 
3939
Version 8.0.<BR>
 
3940
<BR>
 
3941
<DT><A NAME="LaTeX:intro"><FONT COLOR=purple>[16]</FONT></A><DD>
 
3942
Tobias Oetiker.
 
3943
<EM>The Not So Short Introduction to L<sup>A</sup>T<sub>E</sub>X2e</EM>, January 1999.<BR>
 
3944
<BR>
 
3945
<DT><A NAME="Pau96b"><FONT COLOR=purple>[17]</FONT></A><DD>
 
3946
Christine Paulin-Mohring.
 
3947
<EM>D�finitions Inductives en Th�orie des Types d'Ordre Sup�rieur</EM>.
 
3948
Habilitation � diriger les recherches, Universit� Claude Bernard Lyon
 
3949
 I, December 1996.</DL>
 
3950
 
 
3951
 
 
3952
 
 
3953
 
 
3954
 
 
3955
<!--HTMLFOOT-->
 
3956
<!--ENDHTML-->
 
3957
<!--FOOTER-->
 
3958
<HR SIZE=2>
 
3959
<BLOCKQUOTE><EM>This document was translated from L<sup>A</sup>T<sub>E</sub>X by
 
3960
</EM><A HREF="http://pauillac.inria.fr/~maranget/hevea/index.html"><EM>H<FONT SIZE=2><sup>E</sup></FONT>V<FONT SIZE=2><sup>E</sup></FONT>A</EM></A><EM>.
 
3961
</EM></BLOCKQUOTE>
 
3962
</BODY>
 
3963
</HTML>