Skip to content

Commit 1c30f04

Browse files
committed
small corrections
1 parent a39d739 commit 1c30f04

File tree

4 files changed

+30
-37
lines changed

4 files changed

+30
-37
lines changed

doc/chapter-primrec.tex

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,18 +413,10 @@ \subsubsection{Using function composition}
413413

414414
Let us look at the proof that any constant $n$ of type \texttt{nat} has type (\texttt{PR 0})
415415
(lemma \texttt{const0\_NIsPR} of \texttt{primRec}). We carry out a proof by induction on $n$, the base case of which is already proven.
416-
Now, let us assume $n$ is \texttt{PR $0$}, with $x:\texttt{PrimRec}\,0$ as a ``realizer''.
416+
Now, let us assume $n$ is \texttt{PR $0$}, and call $(x:\texttt{PrimRec}\,0)$ its ``realizer''.
417417
Thus we would like to compose this constant function with the unary successor function.
418418

419-
This is exactly the role of the instance \texttt{composeFunc 0 1} of the dependently typed
420-
function \texttt{composeFunc}, as shown by the following lemma.
421-
422-
\vspace{4pt}
423-
\input{movies/snippets/PrimRecExamples/compose01}
424-
425-
426-
\vspace{4pt}
427-
Here is a quite simple proof of \texttt{const0\_NIsPR}.
419+
This is exactly the role of the function \texttt{(composeFunc 0 1)}. Here is a quite simple proof of \texttt{const0\_NIsPR}.
428420

429421

430422
\vspace{4pt}
@@ -435,13 +427,13 @@ \subsubsection{Using function composition}
435427

436428
\subsubsection{Another proof that \texttt{Nat.add} is primitive recursive}
437429

438-
We have already proven that \texttt{Nat.add} is primitive recursive. The following alternative proof, --- more detalled ---,
430+
We have already proven that \texttt{Nat.add} is primitive recursive. The following alternative proof, --- more detailed ---,
439431
shows how to search and apply lemmas from
440432
the \texttt{Ackermann} library.
441433

442434

443435

444-
Let us look for some lemma which could help to prove some
436+
Let us look for some lemma which could help to prove a given
445437
recursive arithmetic binary function is primitive recursive.
446438

447439
\inputsnippets{PrimRecExamples/PRnatRecSearch}

doc/hydras.tex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,15 @@ \part{Hydras and ordinals}
556556
\include{Gamma0-chapter}
557557

558558

559-
%\part{Ackermann, G\"{o}del, Peano\,\dots}
559+
\part{Ackermann, G\"{o}del, Peano\,\dots}
560560

561-
%\include{chap-intro-goedel}
561+
\include{chap-intro-goedel}
562562
\include{chapter-primrec}
563-
% \include{chapter-fol}
564-
% \include{chapter-natural-deduction}
565-
% \include{chapter-lnn-lnt}
566-
% \include{chapter-encoding}
567-
% \include{chapter-expressible}
563+
\include{chapter-fol}
564+
\include{chapter-natural-deduction}
565+
\include{chapter-lnn-lnt}
566+
\include{chapter-encoding}
567+
\include{chapter-expressible}
568568

569569

570570
\part{A few certified algorithms}

theories/ordinals/Ackermann/primRec.v

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ Fixpoint evalPrimRec (n : nat) (f : PrimRec n) {struct f} :
231231
Notation PReval f := (evalPrimRec _ f).
232232
Notation PRevalN fs := (evalPrimRecs _ _ fs).
233233

234+
(** [p] is a correct implementation of [f] in [PrimRec n] *)
235+
236+
Definition PRcorrect {n:nat}(p:PrimRec n)(f: naryFunc n) :=
237+
PReval p =x= f.
238+
234239
(* end snippet evalPrimRecDef *)
235240

236241
Definition extEqualVectorGeneral (n m : nat) (l : Vector.t (naryFunc n) m) :
@@ -331,7 +336,7 @@ Qed.
331336
Class isPR (n : nat) (f : naryFunc n) : Set :=
332337
is_pr : {p : PrimRec n | extEqual n (PReval p) f}.
333338

334-
Definition fun2PR {n:nat}(f: naryFunc n)
339+
Definition fun2PR {n:nat}(f: naryFunc n)
335340
{p: isPR _ f}: PrimRec n := proj1_sig p.
336341

337342
Class isPRrel (n : nat) (R : naryRel n) : Set :=

theories/ordinals/MoreAck/PrimRecExamples.v

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ Compute PReval fact 5.
170170
(* end snippet tests *)
171171

172172
(* begin snippet correctness:: no-out *)
173-
Lemma cst0_correct : (PReval cst0) =x= (fun _ => 0).
173+
174+
Lemma cst0_correct : PRcorrect cst0 (fun _ => 0).
174175
Proof. intros ?; reflexivity. Qed.
175176

176-
Lemma cst_correct (k:nat) : PReval (cst k) =x= (fun _ => k).
177+
Lemma cst_correct (k:nat) : PRcorrect (cst k) (fun _ => k).
177178
Proof.
178179
induction k as [| k IHk]; simpl; intros p.
179180
- reflexivity.
180-
- now rewrite IHk.
181+
- cbn; now rewrite IHk.
181182
Qed.
182183

183-
Lemma plus_correct:
184-
PReval plus =x= Nat.add.
184+
Lemma plus_correct: PRcorrect plus Nat.add.
185185
Proof.
186186
intros n; induction n as [ | n IHn].
187187
- intro; reflexivity.
@@ -193,15 +193,15 @@ Remark mult_eqn1 n p:
193193
PReval plus (PReval mult n p) p.
194194
Proof. reflexivity. Qed.
195195

196-
Lemma mult_correct: PReval mult =x= Nat.mul.
196+
Lemma mult_correct: PRcorrect mult Nat.mul.
197197
Proof.
198198
intro n; induction n as [ | n IHn].
199199
- intro p; reflexivity.
200200
- intro p; rewrite mult_eqn1, (IHn p) , plus_correct. cbn. ring.
201201
Qed.
202202

203203

204-
Lemma fact_correct : PReval fact =x= Coq.Arith.Factorial.fact.
204+
Lemma fact_correct : PRcorrect fact Coq.Arith.Factorial.fact.
205205
(* ... *)
206206
(* end snippet correctness *)
207207
Proof.
@@ -222,14 +222,13 @@ Qed.
222222
These lemmas are trivial and theoretically useless, but they may help to
223223
make the construction more concrete *)
224224

225-
Definition PRcompose1 (g f : PrimRec 1) : PrimRec 1 :=
226-
PRcomp g [f]%pr.
225+
Definition PRcompose1 (g f : PrimRec 1) : PrimRec 1 := PRcomp g [f]%pr.
227226

228227
Goal forall f g x, evalPrimRec 1 (PRcompose1 g f) x =
229228
evalPrimRec 1 g (evalPrimRec 1 f x).
230229
Proof. reflexivity. Qed.
231230

232-
Remark compose2_0 (a:nat) (g: nat -> nat) : compose2 0 a g = g a.
231+
Remark compose2_0 (a:nat) (g: nat -> nat) : compose2 0 a g = g a.
233232
Proof. reflexivity. Qed.
234233

235234
Remark compose2_1 (f: nat -> nat) (g : nat -> nat -> nat) x
@@ -349,16 +348,13 @@ Proof. reflexivity. Qed.
349348

350349
#[export] Instance const0_NIsPR n : isPR 0 n. (* .no-out *)
351350
Proof. (* .no-out *)
352-
induction n. (* .no-out *)
353-
- apply zeroIsPR. (* .no-out *)
354-
- destruct IHn as [x Hx].
355-
exists (PRcomp succFunc [x])%pr; cbn in *; intros;
356-
now rewrite Hx.
351+
induction n as [ | n [x Hx]].
352+
- (* .no-out *) apply zeroIsPR.
353+
- (* .no-out *) exists (composeFunc _ _ [x] succFunc)%pr; cbn in *; intros;
354+
now rewrite Hx. (* .no-out *)
357355
Qed.
358356
(* end snippet const0NIsPR *)
359357

360-
361-
362358
(* begin snippet PRnatRecSearch *)
363359
Search (isPR 2 (fun _ _ => nat_rec _ _ _ _)).
364360
(* end snippet PRnatRecSearch *)

0 commit comments

Comments
 (0)