mirror of
https://github.com/achlipala/frap.git
synced 2024-11-28 07:16:20 +00:00
preparing Ltac lecture
This commit is contained in:
parent
728a8255f8
commit
f5ca4613d7
2 changed files with 20 additions and 1 deletions
|
@ -483,6 +483,25 @@ Goal False.
|
||||||
length (1 :: 2 :: 3 :: nil) ltac:(fun n => pose n).
|
length (1 :: 2 :: 3 :: nil) ltac:(fun n => pose n).
|
||||||
Abort.
|
Abort.
|
||||||
|
|
||||||
|
(* However, it's not always convenient to use continuation passing style
|
||||||
|
* everywhere, so cool kids use the following hack to sneak side effects
|
||||||
|
* into otherwise functional Ltac code: *)
|
||||||
|
Module Import WithPrintingFixedWithoutContinuations.
|
||||||
|
Ltac length ls :=
|
||||||
|
let __ := match constr:(Set) with
|
||||||
|
| _ => (* put all your side effects here:*)
|
||||||
|
idtac ls; assert (ls = ls) by equality
|
||||||
|
end in
|
||||||
|
match ls with
|
||||||
|
| nil => constr:(O)
|
||||||
|
| _ :: ?ls' => let L := length ls' in constr:(S L)
|
||||||
|
end.
|
||||||
|
End WithPrintingFixedWithoutContinuations.
|
||||||
|
|
||||||
|
Goal False.
|
||||||
|
let n := length (1 :: 2 :: 3 :: nil) in
|
||||||
|
pose n.
|
||||||
|
Abort.
|
||||||
|
|
||||||
(** * Recursive Proof Search *)
|
(** * Recursive Proof Search *)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ Inductive fact_state :=
|
||||||
* throughout recursive invocations of a predicate (though this definition does
|
* throughout recursive invocations of a predicate (though this definition does
|
||||||
* not use recursion). After the colon, we give a type that expresses which
|
* not use recursion). After the colon, we give a type that expresses which
|
||||||
* additional arguments exist, followed by [Prop] for "proposition."
|
* additional arguments exist, followed by [Prop] for "proposition."
|
||||||
* Putting this inductive definition in [Prop] is what marks at as a predicate.
|
* Putting this inductive definition in [Prop] is what marks it as a predicate.
|
||||||
* Our prior definitions have implicitly been in [Set], the normal universe
|
* Our prior definitions have implicitly been in [Set], the normal universe
|
||||||
* of mathematical objects. *)
|
* of mathematical objects. *)
|
||||||
Inductive fact_init (original_input : nat) : fact_state -> Prop :=
|
Inductive fact_init (original_input : nat) : fact_state -> Prop :=
|
||||||
|
|
Loading…
Reference in a new issue