Mercurial > cpdt > repo
comparison src/LogicProg.v @ 459:9fbf3b4dac29
Proofreading pass through Chapter 13
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 29 Aug 2012 14:11:26 -0400 |
parents | 0650420c127b |
children | b36876d4611e |
comparison
equal
deleted
inserted
replaced
458:b750ec0a8edb | 459:9fbf3b4dac29 |
---|---|
124 Error: Impossible to unify "plusR 0 ?27 ?27" with "plusR 1 3 4". | 124 Error: Impossible to unify "plusR 0 ?27 ?27" with "plusR 1 3 4". |
125 >> *) | 125 >> *) |
126 apply PlusS. | 126 apply PlusS. |
127 apply PlusO. | 127 apply PlusO. |
128 | 128 |
129 (** At this point the proof is completed. It is no doubt clear that a simple procedure could find all proofs of this kind for us. We are just exploring all possible proof trees, built from the two candidate steps [apply PlusO] and [apply PlusS]. The built-in tactic %\index{tactics!auto}%[auto] does exactly that, since above we used [Hint Constructors] to register the two candidate proof steps as hints. *) | 129 (** At this point the proof is completed. It is no doubt clear that a simple procedure could find all proofs of this kind for us. We are just exploring all possible proof trees, built from the two candidate steps [apply PlusO] and [apply PlusS]. The built-in tactic %\index{tactics!auto}%[auto] does exactly that, since above we used %\index{Vernacular commands!Hint Constructors}%[Hint Constructors] to register the two candidate proof steps as hints. *) |
130 | 130 |
131 Restart. | 131 Restart. |
132 auto. | 132 auto. |
133 Qed. | 133 Qed. |
134 (* end thide *) | 134 (* end thide *) |
147 | 147 |
148 (** This time, [auto] is not enough to make any progress. Since even a single candidate step may lead to an infinite space of possible proof trees, [auto] is parameterized on the maximum depth of trees to consider. The default depth is 5, and it turns out that we need depth 6 to prove the goal. *) | 148 (** This time, [auto] is not enough to make any progress. Since even a single candidate step may lead to an infinite space of possible proof trees, [auto] is parameterized on the maximum depth of trees to consider. The default depth is 5, and it turns out that we need depth 6 to prove the goal. *) |
149 | 149 |
150 auto 6. | 150 auto 6. |
151 | 151 |
152 (** Sometimes it is useful to see a description of the proof tree that [auto] finds, with the %\index{tactics!info}%[info] tactical. (This tactical is not available in Coq 8.4 as of this writing, but I hope it reappears soon.) *) | 152 (** Sometimes it is useful to see a description of the proof tree that [auto] finds, with the %\index{tactics!info}%[info] tactical. (This tactical is not available in Coq 8.4 as of this writing, but I hope it reappears soon. The special case %\index{tactics!info\_auto}%[info_auto] tactic is provided as a chatty replacement for [auto].) *) |
153 | 153 |
154 Restart. | 154 Restart. |
155 info auto 6. | 155 info auto 6. |
156 (** %\vspace{-.15in}%[[ | 156 (** %\vspace{-.15in}%[[ |
157 == apply PlusS; apply PlusS; apply PlusS; apply PlusS; | 157 == apply PlusS; apply PlusS; apply PlusS; apply PlusS; |
189 | 189 |
190 Next we demonstrate unification, which will be easier when we switch to the relational formulation of addition. *) | 190 Next we demonstrate unification, which will be easier when we switch to the relational formulation of addition. *) |
191 | 191 |
192 Example seven_minus_three' : exists x, plusR x 3 7. | 192 Example seven_minus_three' : exists x, plusR x 3 7. |
193 (* begin thide *) | 193 (* begin thide *) |
194 (** We could attempt to guess the quantifier instantiation manually as before, but here there is no need. Instead of [apply], we use %\index{tactics!eapply}%[eapply] instead, which proceeds with placeholder%\index{unification variable}% _unification variables_ standing in for those parameters we wish to postpone guessing. *) | 194 (** We could attempt to guess the quantifier instantiation manually as before, but here there is no need. Instead of [apply], we use %\index{tactics!eapply}%[eapply], which proceeds with placeholder%\index{unification variable}% _unification variables_ standing in for those parameters we wish to postpone guessing. *) |
195 | 195 |
196 eapply ex_intro. | 196 eapply ex_intro. |
197 (** [[ | 197 (** [[ |
198 1 subgoal | 198 1 subgoal |
199 | 199 |
390 ]] | 390 ]] |
391 *) | 391 *) |
392 Abort. | 392 Abort. |
393 End slow. | 393 End slow. |
394 | 394 |
395 (** Sometimes, though, transitivity is just what is needed to get a proof to go through automatically with [eauto]. For those cases, we can use named%\index{hint databases}% _hint databases_ to segragate hints into different groups that may be called on as needed. Here we put [eq_trans] into the database [slow]. *) | 395 (** Sometimes, though, transitivity is just what is needed to get a proof to go through automatically with [eauto]. For those cases, we can use named%\index{hint databases}% _hint databases_ to segregate hints into different groups that may be called on as needed. Here we put [eq_trans] into the database [slow]. *) |
396 | 396 |
397 (* begin thide *) | 397 (* begin thide *) |
398 Hint Resolve eq_trans : slow. | 398 Hint Resolve eq_trans : slow. |
399 (* end thide *) | 399 (* end thide *) |
400 | 400 |
557 (Forall_cons 1 (le_n 1) | 557 (Forall_cons 1 (le_n 1) |
558 (Forall_cons 1 (le_n 1) (Forall_nil (fun n : nat => n >= 1))))) | 558 (Forall_cons 1 (le_n 1) (Forall_nil (fun n : nat => n >= 1))))) |
559 ]] | 559 ]] |
560 *) | 560 *) |
561 | 561 |
562 (** Let us try one more, fancier example. First, we use a standard high-order function to define a function for summing all data elements of a list. *) | 562 (** Let us try one more, fancier example. First, we use a standard higher-order function to define a function for summing all data elements of a list. *) |
563 | 563 |
564 Definition sum := fold_right plus O. | 564 Definition sum := fold_right plus O. |
565 | 565 |
566 (** Another basic lemma will be helpful to guide proof search. *) | 566 (** Another basic lemma will be helpful to guide proof search. *) |
567 | 567 |
861 | 861 |
862 auto. | 862 auto. |
863 Qed. | 863 Qed. |
864 (* end thide *) | 864 (* end thide *) |
865 | 865 |
866 (** We see that an [Extern] pattern may bind unification variables that we use in the associated tactic. The function [proj1] is from the standard library, for extracting a proof of [R] from a proof of [R /\ S]. *) | 866 (** We see that an [Extern] pattern may bind unification variables that we use in the associated tactic. The function [proj1] is from the standard library, for extracting a proof of [U] from a proof of [U /\ V]. *) |
867 | 867 |
868 End forall_and. | 868 End forall_and. |
869 | 869 |
870 (* begin hide *) | 870 (* begin hide *) |
871 (* begin thide *) | 871 (* begin thide *) |