mirror of
https://github.com/achlipala/frap.git
synced 2024-11-28 07:16:20 +00:00
Proofreading LogicProgramming
This commit is contained in:
parent
078e29f8a9
commit
c8cfde5acf
1 changed files with 9 additions and 10 deletions
|
@ -380,7 +380,7 @@ Proof.
|
||||||
|
|
||||||
(* Coq leaves for us two subgoals to prove... [nat]?! We are being asked to
|
(* Coq leaves for us two subgoals to prove... [nat]?! We are being asked to
|
||||||
* show that natural numbers exists. Why? Some unification variables of that
|
* show that natural numbers exists. Why? Some unification variables of that
|
||||||
* type were left undetermiend, by the end of the proof. Specifically, these
|
* type were left undetermined, by the end of the proof. Specifically, these
|
||||||
* variables stand for the 2 elements of the list we find. Of course it makes
|
* variables stand for the 2 elements of the list we find. Of course it makes
|
||||||
* sense that the list length follows without knowing the data values. In Coq
|
* sense that the list length follows without knowing the data values. In Coq
|
||||||
* 8.6, the [Unshelve] command brings these goals to the forefront, where we
|
* 8.6, the [Unshelve] command brings these goals to the forefront, where we
|
||||||
|
@ -394,7 +394,7 @@ Proof.
|
||||||
Show Proof.
|
Show Proof.
|
||||||
Abort.
|
Abort.
|
||||||
|
|
||||||
(* Paradoxically, we can make the proof search process easier by constraining
|
(* Paradoxically, we can make the proof-search process easier by constraining
|
||||||
* the list further, so that proof search naturally locates appropriate data
|
* the list further, so that proof search naturally locates appropriate data
|
||||||
* elements by unification. The library predicate [Forall] will be helpful. *)
|
* elements by unification. The library predicate [Forall] will be helpful. *)
|
||||||
|
|
||||||
|
@ -410,9 +410,8 @@ Qed.
|
||||||
|
|
||||||
Print length_is_2.
|
Print length_is_2.
|
||||||
|
|
||||||
(* Let us try one more, fancier example. First, we use a standard higher
|
(* Let us try one more, fancier example. First, we use a standard higher-order
|
||||||
* order function to define a function for summing all data elements of a
|
* function to define a function for summing all data elements of a list. *)
|
||||||
* list. *)
|
|
||||||
|
|
||||||
Definition sum := fold_right plus O.
|
Definition sum := fold_right plus O.
|
||||||
|
|
||||||
|
@ -693,8 +692,8 @@ Proof.
|
||||||
induct e; first_order; eauto.
|
induct e; first_order; eauto.
|
||||||
Qed.
|
Qed.
|
||||||
|
|
||||||
(* Here's a quick tease using a feature that we'll explore fully this time next
|
(* Here's a quick tease using a feature that we'll explore fully in a later
|
||||||
* week. Let's use a mysterious construct [sigT] instead of [exists]. *)
|
* class. Let's use a mysterious construct [sigT] instead of [exists]. *)
|
||||||
|
|
||||||
Hint Extern 1 (sigT (fun n : nat => _)) => exists 0.
|
Hint Extern 1 (sigT (fun n : nat => _)) => exists 0.
|
||||||
Hint Extern 1 (sigT (fun n : nat => _)) => exists 1.
|
Hint Extern 1 (sigT (fun n : nat => _)) => exists 1.
|
||||||
|
@ -706,11 +705,11 @@ Proof.
|
||||||
induct e; first_order; eauto.
|
induct e; first_order; eauto.
|
||||||
Defined.
|
Defined.
|
||||||
|
|
||||||
(* Essentially the same proof search ahs completed. This time, though, we ended
|
(* Essentially the same proof search has completed. This time, though, we ended
|
||||||
* the proof with [Defined], which saves it as _transparent_, so details of the
|
* the proof with [Defined], which saves it as _transparent_, so details of the
|
||||||
* "proof" can be consulted from the outside. Actually, this "proof" is more
|
* "proof" can be consulted from the outside. Actually, this "proof" is more
|
||||||
* like a recursive program that finds [k] and [n], given [e]! Let's add a
|
* like a recursive program that finds [k] and [n], given [e]! Let's add a
|
||||||
* wrapper to make taht idea more concrete. *)
|
* wrapper to make that idea more concrete. *)
|
||||||
|
|
||||||
Definition params (e : exp) : nat * nat :=
|
Definition params (e : exp) : nat * nat :=
|
||||||
let '(existT _ k (existT _ n _)) := linear_computable e in
|
let '(existT _ k (existT _ n _)) := linear_computable e in
|
||||||
|
@ -885,7 +884,7 @@ Hint Extern 1 =>
|
||||||
(** * Rewrite Hints *)
|
(** * Rewrite Hints *)
|
||||||
|
|
||||||
(* Another dimension of extensibility with hints is rewriting with quantified
|
(* Another dimension of extensibility with hints is rewriting with quantified
|
||||||
* equalities. We have used the associated command %[Hint Rewrite] in several
|
* equalities. We have used the associated command [Hint Rewrite] in several
|
||||||
* examples so far. The [simplify] tactic uses these hints by calling the
|
* examples so far. The [simplify] tactic uses these hints by calling the
|
||||||
* built-in tactic [autorewrite]. Our rewrite hints have taken the form
|
* built-in tactic [autorewrite]. Our rewrite hints have taken the form
|
||||||
* [Hint Rewrite lemma], which by default adds them to the default hint database
|
* [Hint Rewrite lemma], which by default adds them to the default hint database
|
||||||
|
|
Loading…
Reference in a new issue