Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion. • 84 items • Updated • 3
fact stringlengths 3 13.4k | type stringclasses 21
values | library stringclasses 6
values | imports listlengths 0 6 | filename stringclasses 137
values | symbolic_name stringlengths 1 29 | docstring stringclasses 1
value |
|---|---|---|---|---|---|---|
test : abs_evars (forall x, x = x). intros t x; reflexivity. Abort. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_abs_evars.v | test | |
test : abs_evars (forall x y, x = y). intros t x y; symmetry. Abort. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_abs_evars.v | test | |
test : True. assert (abs_evars (tt = _)) as H. intro x; destruct x; reflexivity. Abort. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_abs_evars.v | test | |
test : exists x, x = tt. econstructor. (* it is silly, but shows the code above performs the abstraction *) elpi abs_evars. now intros []. exact tt. Qed. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_abs_evars.v | test | |
l0 x y z (H : x < y) : y < z -> x < z. Proof. elpi id. Abort. (* Things are wired up in such a way that assigning a "wrong" value to Ev fails *) Elpi Tactic silly. Elpi Accumulate lp:{{ solve (goal _ Ev _ _ _) _ :- Ev = {{true}}. solve (goal _ Ev _ _ _) _ :- Ev = {{3}}. }}. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_curry_howard_tactics.v | l0 | |
l1 : nat. Proof. elpi silly. Show Proof. Qed. (* Now we write "intro" in Curry-Howard style *) Elpi Tactic intro. Elpi Accumulate lp:{{ solve (goal _ _ _ _ [str S] as G) GS :- coq.string->name S N, refine (fun N Src_ Tgt_) G GS. }}. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_curry_howard_tactics.v | l1 | |
l2 x y z (H : x < y) : y < z -> x < z. Proof. elpi intro H1. Abort. (* Now let's write a little automation *) Elpi Tactic auto. Elpi Accumulate lp:{{ shorten coq.ltac.{ open , or , repeat }. pred intro i:name, i:goal, o:list sealed-goal. intro S G GS :- refine (fun S Src_ Tgt_) G GS. % Ex falso pred exf i:goal, o:list ... | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_curry_howard_tactics.v | l2 | |
l3 : forall P : Prop, (False -> P) /\ (False \/ True). Proof. elpi auto. Qed. | Lemma | examples | [
"From elpi Require Import elpi."
] | examples/example_curry_howard_tactics.v | l3 | |
ty := B | N. | Inductive | examples | [
"From elpi Require Import elpi."
] | examples/example_fuzzer.v | ty | |
Exp : ty -> Type := | NUM : nat -> Exp N | BOOL : bool -> Exp B | PLUS : Exp N -> Exp N -> Exp N | AND : Exp B -> Exp B -> Exp B | OR : Exp B -> Exp B-> Exp B | EQ : Exp N -> Exp N -> Exp B. | Inductive | examples | [
"From elpi Require Import elpi."
] | examples/example_fuzzer.v | Exp | |
Val : ty -> Set := | iNv : nat -> Val N | iBv : bool -> Val B. | Inductive | examples | [
"From elpi Require Import elpi."
] | examples/example_fuzzer.v | Val | |
eval : forall {T: ty}, Exp T -> Val T -> Prop := | E_Num n : eval (NUM n) (iNv n) | E_Bool b : eval (BOOL b) (iBv b) | E_Plus e1 e2 n1 n2 : eval e1 (iNv n1) -> eval e2 (iNv n2) -> eval (PLUS e1 e2) (iNv (n1 + n2)) | E_AND e1 e2 b1 b2 : eval e1 (iBv b1) -> eval e2 (iBv b2) -> eval (AND e1 e2) (iBv (b1 && b2)) | E_OR e1 ... | Inductive | examples | [
"From elpi Require Import elpi."
] | examples/example_fuzzer.v | eval | |
r T (t : T) := Build { p1 : nat; p2 : t = t; _ : p2 = refl_equal; }. | Record | examples | [
"From elpi Require Import elpi."
] | examples/example_import_projections.v | r | |
r1 (A : Type) : Type := { f1 : A; f2 : nat; }. | Record | examples | [
"From elpi Require Import elpi."
] | examples/example_import_projections.v | r1 | |
r := mk { proj1 : T1; proj2 : T2 }. | Record | examples | [
"From elpi Require Import elpi."
] | examples/example_record_expansion.v | r | |
f (x : r) := Body(proj1 x,proj2 x). Is expanded to: | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_record_expansion.v | f | |
f1 v1 v2 := Body(v1,v2). And recursively, if g uses f, then g1 must use f1... The idea is to take "f", replace "(x : r)" with as many abstractions as needed in order to write "mk v1 v2", then replace "x" with "mk v1 v2", finally fire iota reductions such as "proj1 (mk v1 v2) = v1" to obtain "f1". Then record a global r... | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_record_expansion.v | f1 | |
r := { T :> Type; X := T; op : T -> X -> bool }. | Record | examples | [
"From elpi Require Import elpi."
] | examples/example_record_expansion.v | r | |
f b (t : r) (q := negb b) := fix rec (l1 l2 : list t) := match l1, l2 with | nil, nil => b | cons x xs, cons y ys => andb (op _ x y) (rec xs ys) | _, _ => q end. Elpi record.expand r f "expanded_". Print f. Print expanded_f. (* so that we can see the new "expand" clause *) Elpi Print record.expand "elpi_examples/record... | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_record_expansion.v | f | |
g t l s h := (forall x y, op t x y = false) /\ f true t l s = h. Elpi record.expand r g "expanded_". Print expanded_g. | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_record_expansion.v | g | |
x := 1. | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_reduction_surgery.v | x | |
y := 1. | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_reduction_surgery.v | y | |
alias := plus. | Definition | examples | [
"From elpi Require Import elpi."
] | examples/example_reduction_surgery.v | alias | |
bool2nat (b : bool) := if b then 1 else 0. Fail Elpi check_arg (1 = true). (* .fails *) Check (1 = true). (*| The command still fails even if we told Coq how to inject booleans values into the natural numbers. Indeed the `Check` commands works. The call to :builtin:`coq.typecheck` modifies the term in place, it can ass... | Coercion | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_command.v | bool2nat | |
how :e:`T` is not touched by the call to this API, and how :e:`T1` is a copy of :e:`T` where the hole after `eq` is synthesized and the value `true` injected to `nat` by using `bool2nat`. It is also possible to manipulate term arguments before typechecking them, but note that all the considerations on holes in the tuto... | Remark | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_command.v | how | |
tree := leaf | node : tree -> option nat -> tree -> tree. Elpi abstract tree (option nat). Print tree'. (*| As expected `tree'` has a parameter `A`. Now let's focus on :lib:`copy`. The standard coq library (loaded by the command template) contains a definition of copy for terms and declarations. An excerpt: .. code:: e... | Inductive | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_command.v | tree | |
w := 3. | Definition | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_command.v | w | |
x := 2. Elpi Query lp:{{ coq.locate "x" GR, % all global references have a type coq.env.typeof GR Ty, % destruct GR to obtain its constant part C GR = const C, % constants may have a body, do have a type coq.env.const C (some Bo) TyC }}. (*| An expression like :e:`indt «nat»` is not a Coq term (or better a type) yet. T... | Definition | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_HOAS.v | x | |
f := fun x : nat => x. Elpi Query lp:{{ coq.locate "f" (const C), coq.env.const C (some Bo) _ }}. (*| The :constructor:`fun` constructor carries a pretty printing hint ```x```, the type of the bound variable `nat` and a function describing the body: .. code:: elpi type fun name -> term -> (term -> term) -> term. .. not... | Definition | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_HOAS.v | f | |
m (h : 0 = 1 ) P : P 0 -> P 1 := match h as e in eq _ x return P 0 -> P x with eq_refl => fun (p : P 0) => p end. Elpi Query lp:{{ coq.locate "m" (const C), coq.env.const C (some (fun _ _ h\ fun _ _ p\ match _ (RT h p) _)) _, coq.say "The return type of m is:" RT }}. (*| --------------------- Constructor :e:`sort` ----... | Definition | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_HOAS.v | m | |
nat2bool n := match n with O => false | _ => true end. Open Scope bool_scope. Elpi Query lp:{{ T = {{ fun x : nat => x && _ }}, T = fun N Ty Bo, Bo1 = Bo {{ 1 }}, coq.elaborate-skeleton Bo1 {{ bool }} Bo2 ok }}. (*| Here :e:`Bo2` is obtained by taking :e:`Bo1`, considering all unification variables as holes and all `{{... | Coercion | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_coq_elpi_HOAS.v | nat2bool | |
tutorial x y : x + 1 = y. elpi show. (* .in .messages *) Abort. (*| In the Elpi code up there :e:`Proof` is the hole for the current goal, :e:`Type` the statement to be proved and :e:`Ctx` the proof context (the list of hypotheses). Since we don't assign :e:`Proof` the tactic makes no progress. Elpi prints somethinglik... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | tutorial | |
test_blind : True * nat. Proof. (* .in *) split. - elpi blind. - elpi blind. Show Proof. (* .in .messages *) Qed. (*| Since the assignment of a term to :e:`Trigger` triggers its elaboration against the expected type (the goal statement), assigning the wrong proof term results in a failure which in turn results in the o... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_blind | |
test_blind2 : True * nat. Proof. (* .in *) split. - elpi blind2. - elpi blind2. Qed. (*| This schema works even if the term is partial, that is if it contains holes corresponding to missing sub proofs. Let's write a tactic which opens a few subgoals, for example let's implement the `split` tactic. .. important:: Elpi's... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_blind2 | |
test_split : exists t : Prop, True /\ True /\ t. Proof. (* .in *) eexists. repeat elpi split. (* The failure is caught by Ltac's repeat *) (* Remark that the last goal is left untouched, since it did not match the pattern {{ _ /\ _ }}. *) all: elpi blind. Show Proof. (* .in .messages *) Qed. (*| The tactic `split` succ... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_split | |
helper_split2 n t := fail n || apply t. Elpi Tactic split2. Elpi Accumulate lp:{{ solve (goal _ _ {{ _ /\ _ }} _ _ as G) GL :- coq.ltac.call "helper_split2" [int 0, trm {{ conj }}] G GL. solve _ _ :- coq.ltac.fail _ "not a conjunction". }}. | Ltac | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | helper_split2 | |
test_split2 : exists t : Prop, True /\ True /\ t. Proof. (* .in *) eexists. repeat elpi split2. all: elpi blind. Qed. (*| ============================= Arguments and Tactic Notation ============================= Elpi tactics can receive arguments. Arguments are received as a list, which is the last argument of the goal... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_split2 | |
test_print_args : True. (* .in *) elpi print_args 1 x "a b" (1 = 0). (* .in .messages *) Abort. (*| The convention is that numbers like `1` are passed as :e:`int 1`, identifiers or strings are passed as :e:`str "arg"` and terms have to be put between parentheses. .. important:: terms are received in raw format, eg befo... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_print_args | |
test_refine (P Q : Prop) (H : P -> Q) : Q. Proof. (* .in *) Fail elpi refine (H). (* .fails *) elpi refine (H _). Abort. (*| -------------------------------- | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_refine | |
arguments to Elpi arguments -------------------------------- It is customary to use the Tactic Notation command to attach a nicer syntax to Elpi tactics. In particular `elpi tacname` accepts as arguments the following `bridges for Ltac values <https://coq.inria.fr/doc/master/refman/proof-engine/ltac.html#syntactic-valu... | Ltac | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | arguments | |
test_use (P Q : Prop) (H : P -> Q) (p : P) : Q. Proof. (* .in *) use (H _). Fail use q. (* .fails .in .messages *) use p. Qed. Tactic Notation "print" uconstr_list_sep(l, ",") := elpi print_args ltac_term_list:(l). | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_use | |
test_print (P Q : Prop) (H : P -> Q) (p : P) : Q. print P, p, (H p). (* .in .messages *) Abort. (*| ======== Failure ======== The :builtin:`coq.error` aborts the execution of both Elpi and any enclosing Ltac context. This failure cannot be caught by Ltac. On the contrary the :builtin:`coq.ltac.fail` builtin can be used... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_print | |
test_assumption (P Q : Prop) (p : P) (q : Q) : P /\ id Q. Proof. (* .in *) split. elpi assumption. Fail elpi assumption. (* .fails *) Abort. (*| As we hinted before, Elpi's equality is alpha equivalence. In the second goal the assumption has type `Q` but the goal has type `id Q` which is convertible (unifiable, for Coq... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_assumption | |
test_assumption2 (P Q : Prop) (p : P) (q : Q) : P /\ id Q. Proof. (* .in *) split. all: elpi assumption2. Qed. (*| :libtac:`refine` does unify the type of goal with the type of the term, hence we can simplify the code further. We obtain a tactic very similar to our initial `blind` tactic, which picks candidates from th... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_assumption2 | |
test_assumption3 (P Q : Prop) (p : P) (q : Q) : P /\ id Q. Proof. (* .in *) split. all: elpi assumption3. Qed. (*| ------------------------ Let's code `set` in Elpi ------------------------ The `set` tactic takes a term, possibly with holes, and makes a let-in out of it. It gives us the occasion to explain the :lib:`co... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_assumption3 | |
test_find (P Q : Prop) : (P /\ P) \/ (P /\ Q). Proof. (* .in *) elpi find (P). Fail elpi find (Q /\ _). (* .fails .in .messages *) elpi find (P /\ _). Abort. (*| This first approximation only prints the term it found, or better the first instance of the given term. Now lets focus on :lib:`copy`. An excerpt: .. code:: e... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_find | |
test_set (P Q : Prop) : (P /\ P) \/ (P /\ Q). Proof. (* .in *) elpi set "x" (P). unfold x. Fail elpi set "x" (Q /\ _). (* .fails .in .messages *) elpi set "x" (P /\ _). Abort. (*| For more examples of (basic) tactics written in Elpi see the `eltac app <https://github.com/LPCIC/coq-elpi/tree/master/apps/eltac>`_. .. _Th... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_set | |
test_show_more x : x + 1 = 0. elpi show_more. (* .in .messages *) Abort. (*| In addition to the goal we print the Elpi and Coq proof state, plus the link between them. The proof state is the collection of goals together with their types. On the Elpi side this state is represented by constraints for the :e:`evar` predic... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_show_more | |
test_split_ll : exists t : Prop, True /\ True /\ t. Proof. (* .in *) eexists. repeat elpi split_ll. all: elpi blind. Qed. (*| Crafting by hand the list of subgoal is not easy. In particular here we did not set up the new trigger for :e:`Pa` and :e:`Pb`, nor seal the goals appropriately (we did not bind proof variables)... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_split_ll | |
test_split_ll_bis : exists t : Prop, True /\ True /\ t. Proof. (* .in *) eexists. repeat elpi split_ll_bis. all: elpi blind. Qed. (*| At the light of that, :libtac:`refine` is simply: .. code:: elpi refine T (goal _ RawEv _ Ev _) GS :- RawEv = T, coq.ltac.collect-goals Ev GS _. Now that we know the low level plumbing, ... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_split_ll_bis | |
test_undup (P Q : Prop) : P /\ Q. Proof. (* .in *) split. all: elpi ngoals. Abort. (*| This simple tactic prints the number of goals it receives, as well as the list itself. We see something like: .. mquote:: .s(elpi ngoals).msg{*goals =*} :language: text .. mquote:: .s(elpi ngoals).msg{*nabla*} :language: elpi :constr... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_undup | |
test_undup (P Q : Prop) (p : P) (q : Q) : P /\ Q /\ P. Proof. (* .in *) repeat split. Show Proof. (* .in .messages *) all: elpi undup. Show Proof. (* .in .messages *) - apply p. - apply q. Qed. (*| The two calls to show proof display, respectively: .. mquote:: .s(Show Proof).msg{*conj [?]Goal (conj [?]Goal0 [?]Goal1)*}... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_undup | |
test_argpass (P : Prop) : P -> P. Proof. (* .in *) elpi argpass. Qed. (*| Of course the tactic playing the role of `intro` could communicate back a datum to be passed to what follows .. code:: elpi thenl [ open (tac1 Datum), open (tac2 Datum) ] but the binder structure of :type:`sealed-goal` would prevent :e:`Datum` to... | Lemma | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | test_argpass | |
foo : nat := default. Print foo. | Definition | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | foo | |
bar : list bool := default. Print bar. (*| The grammar entries for Elpi tactics in terms take an arbitrary number of arguments with the limitation that they are all terms: you can't pass a string or an integer as one would normally do. Here we use Coq's primitive integers to pass the search depth (in a compact way). |*... | Definition | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | bar | |
baz : list nat := default 2. Print baz. (*| That is all folks! |*) | Definition | examples | [
"From elpi Require Import elpi.",
"From Corelib Require Import PrimInt63."
] | examples/tutorial_coq_elpi_tactic.v | baz | |
that in the premise the variable :math:`x` is still bound, this time not by a λ-abstraction but by the context :math:`\Gamma, x : A`. In λProlog the context is the set of hypothetical rules and :e:`pi\ ` -quantified variables and is implicitly handled by the runtime of the programming language. A slogan to keep in mind... | Remark | examples | [
"From elpi Require Import elpi."
] | examples/tutorial_elpi_lang.v | that | |
map2 : (nat -> nat -> nat) -> list nat -> list nat -> list nat. (* This example make use of the open-trm argument type in order to implement a tactic that takes in input expressions mentioning variables that are bound in the goal (and not in the proof context) *) | Axiom | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | map2 | |
easy_example : forall x, x + 1 = 1 + x. Proof. intros x. (* easy: x is bound by the proof context *) replace (x + 1) with (1 + x) by ring. reflexivity. Qed. | Lemma | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | easy_example | |
hard_example : forall l, map (fun x => x + 1) l = map (fun x => 1 + x) l. Proof. intros l. (* hard: x is bound by a lambda in the goal *) Fail replace (x + 1) with (1 + x) by ring. (* fails and prints: The variable x was not found in the current environment.*) (* This example implements a new repl tactic that will inst... | Lemma | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | hard_example | |
that the technical binders are generated following a left-to-right traversal of the term, hence their order varies. This is the reason why we need the second rule for remove-binder-for. Also remark that L1 and R1 need to see the variable we crossed, and that is bound by pi: we are capturing the free variable by it (or ... | Remark | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | that | |
congrP (A : Type) (B : A -> Type) (f g : forall x : A, B x) : f = g -> forall v1 v2 (p : v1 = v2), match p in _ = x return B x with eq_refl => f v1 end = g v2. Proof. now intros fg v1 v2 v1v2; rewrite fg, v1v2. Qed. | Lemma | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | congrP | |
congrA (A B : Type) (f g : A -> B) : f = g -> forall v1 v2 (p : v1 = v2), f v1 = g v2. Proof. now intros fg v1 v2 v1v2; rewrite fg, v1v2. Qed. Elpi File congruence.code lp:{{ % iterates congrA and congrP to prove f x1..xn = f y1..yn from proofs of xi = yi % [congruence F G PFG Ty XS YS PXYS R] starting from a proof PFG... | Lemma | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | congrA | |
hard_example : forall l, map (fun x => x + 1) l = map (fun x => 1 + x) l. Proof. intros l. repl (x + 1) with (1 + x) by ring. reflexivity. Qed. | Lemma | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | hard_example | |
hard_example2 : forall l, map2 (fun x y => x + 0 + y) l l = map2 (fun x y => y + x) l l. Proof. intros l. repl (x + 0 + y) with (y + x) by ring. reflexivity. Qed. (* An extended version of this tactic by Y. Bertot can be found in the tests/ directory under the name test_open_terms.v *) | Lemma | examples-stdlib | [
"From elpi Require Import elpi.",
"Require Import Arith ZArith List FunctionalExtensionality."
] | examples-stdlib/example_open_terms.v | hard_example2 | |
lang := | var (i : nat) (* i-th variable in the context *) | zero : lang (* Neutral element *) | add (x y : lang). (* binary operation *) (* Interpretation to T *) | Inductive | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | lang | |
interp T (e : T) (op : T -> T -> T) (gamma : list T) (t : lang) : T := match t with | var v => nth v gamma e | zero => e | add x y => op (interp T e op gamma x) (interp T e op gamma y) end. (* normalization of parentheses and units *) | Fixpoint | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | interp | |
normAx t1 acc := match t1 with | add t1 t2 => normAx t1 (normAx t2 acc) | _ => add t1 acc end. | Fixpoint | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normAx | |
normA t := match t with | add s1 s2 => normAx s1 (normA s2) | _ => t end. | Fixpoint | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normA | |
norm1 t := match t with | var _ => t | zero => t | add t1 t2 => match norm1 t1 with | zero => norm1 t2 | t1 => match norm1 t2 with | zero => t1 | t2 => add t1 t2 end end end. | Fixpoint | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm1 | |
norm t := normA (norm1 t). (* Correctness theorem. This is not the point of this demo, please don't look at the proofs ;-) *) | Definition | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm | |
normAxA t1 t2 : normAx t1 (normA t2) = normA (add t1 t2). Proof. by []. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normAxA | |
normAx_add {t1 t2 s} : normAx t1 t2 = s -> exists s1 s2, s = add s1 s2. Proof. elim: t1 t2 s => /= [i||w1 H1 w2 H2] t2 s <-; try by do 2 eexists; reflexivity. by case E: (normAx _ _); case/H1: E => s1 [s2 ->]; do 2 eexists; reflexivity. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normAx_add | |
norm1_zero {l t} : norm1 t = zero -> interp T unit op l t = unit. Proof. by elim: t => [||s1 + s2] //=; case E1: (norm1 s1); case E2: (norm1 s2) => //= -> // ->. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm1_zero | |
norm_zero {l t} : norm t = zero -> interp T unit op l t = unit. Proof. rewrite /norm; case E: (norm1 t) => [||x y] //; first by rewrite (norm1_zero E). by move/normAx_add=> [] ? []. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm_zero | |
norm1_var {l t j} : norm1 t = var j -> interp T unit op l t = nth j l unit. Proof. elim: t => [i [->]||s1 + s2] //=; case E1: (norm1 s1); case E2: (norm1 s2) => //=. by rewrite (norm1_zero E2) unit_r => + _ H => ->. by rewrite (norm1_zero E1) unit_l => _ + H => ->. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm1_var | |
norm_var {l t j} : norm t = var j -> interp T unit op l t = nth j l unit. Proof. rewrite /norm; case E: (norm1 t); rewrite /= ?(norm1_var E) //; first by move=> [->]. by move/normAx_add=> [] ? []. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm_var | |
norm1_add {l t s1 s2} : norm1 t = add s1 s2 -> interp T unit op l t = op (interp T unit op l s1) (interp T unit op l s2). Proof. elim: t s1 s2 => [||w1 + w2 + s1 s2] //=. by case E1: (norm1 w1); case E2: (norm1 w2) => //= ++ [<- <-] /=; do 2! [ move=> /(_ _ _ (refl_equal _)) -> | move=> _]; rewrite ?(norm1_zero E1) ?(n... | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm1_add | |
normAxP {l t1 t2} : interp T unit op l (normAx t1 t2) = op (interp T unit op l t1) (interp T unit op l t2). Proof. by elim: t1 t2 => [||s1 Hs1 s2 Hs2] t2 //=; rewrite Hs1 Hs2 !op_assoc. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normAxP | |
normAP {l} t : interp T unit op l (normA t) = interp T unit op l t. Proof. by elim: t => //= x Hx y Hy; rewrite normAxP Hy. Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normAP | |
norm_add {l t s1 s2} : norm t = add s1 s2 -> interp T unit op l t = op (interp T unit op l s1) (interp T unit op l s2). Proof. rewrite /norm; case E: (norm1 t) => [||x y]; rewrite //= (norm1_add E). elim: x y s1 s2 {E} => //= [>[<- <- //=]|>[<- <-]|x + y + w s1 s2]; rewrite ?normAP //= ?unit_l //. by rewrite normAxA -!... | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | norm_add | |
normP_ l t1 t2 : norm t1 = norm t2 -> interp T unit op l t1 = interp T unit op l t2. Proof. case E: (norm t2) => [?||??] => [/norm_var|/norm_zero|/norm_add] ->. by rewrite (norm_var E). by rewrite (norm_zero E). by rewrite (norm_add E). Qed. | Lemma | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normP_ | |
normP {T e op gamma t1 t2} p1 p2 p3 H := @normP_ T e op p1 p2 p3 gamma t1 t2 H. About normP. Open Scope Z_scope. Goal forall x y z t, (x + y) + (z + 0 + t) = x + (y + z) + t. Proof. intros. change (interp Z Z.zero Z.add (x::y::z::t::nil) (add (add (var 0) (var 1)) (add (add (var 2) zero) (var 3))) = interp Z Z.zero Z.a... | Definition | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | normP | |
my_compute := vm_compute. Elpi Accumulate monoid lp:{{ :before "error" solve (goal _ _ {{ @eq lp:T lp:A lp:B }} _ [] as G) GL :- is_monoid T Zero Op Assoc Ul Ur, quote Zero Op A AstA L, quote Zero Op B AstB L, close L, % This time we use higher level combinators, closer to the standard ltac1 ones refine {{ @normP lp:T ... | Ltac | examples-stdlib | [
"From elpi Require elpi."
] | examples-stdlib/example_reflexive_tactic.v | my_compute | |
myType := Type. | Definition | tests | [
"From elpi Require Import elpi."
] | tests/bug_748.v | myType | |
indd : myType := Indd : indd. | Variant | tests | [
"From elpi Require Import elpi."
] | tests/bug_748.v | indd | |
myType_R u v := u -> v -> Type. Elpi Command foo. Elpi Accumulate " main _ :- std.assert-ok! (coq.typecheck-indt-decl (inductive ""indt_R"" tt (arity {{ myType_R indd indd }}) c1 \ [ constructor ""Indd_R"" (arity {{ lp:c1 Indd Indd }}) ])) ""error"". ". Elpi foo. | Definition | tests | [
"From elpi Require Import elpi."
] | tests/bug_748.v | myType_R | |
x := 3. Elpi Command perf. Elpi Accumulate lp:{{ pred loop i:int, i:gref. loop 0 _. loop M GR :- N is M - 1, (@local! => coq.arguments.set-implicit GR [[]]). loop N GR. main [int N] :- loop N {coq.locate "x"}. }}. Elpi Export perf. Timeout 1 perf 3000. | Definition | tests | [
"From elpi Require Import elpi."
] | tests/perf_calls.v | x | |
succ x := (S x). Elpi Query lp:{{ std.do! [ coq.locate-all "plus" X1, X1 = [loc-gref (const GR)], coq.locate-all "Nat.add" X2, X2 = [loc-gref (const GR)], coq.locate-all "succ" X3, X3 = [loc-abbreviation A_], coq.locate-all "Init.Datatypes" X4, X4 = [loc-modpath MP_], coq.locate-all "fdsfdsjkfdksljflkdsjlkfdjkls" [], ]... | Notation | tests | [
"From elpi Require Import elpi."
] | tests/test_API.v | succ | |
x1 := 3. | Definition | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | x1 | |
x2 := 3. Strategy opaque [x2]. | Definition | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | x2 | |
x3 := 3. Strategy expand [x3]. Elpi Command strategy. Elpi Query lp:{{ coq.locate "x1" (const X1), coq.locate "x2" (const X2), coq.locate "x3" (const X3), coq.strategy.get X1 (level 0), coq.strategy.get X2 opaque, coq.strategy.get X3 expand, coq.strategy.set [X3] (level 123), coq.strategy.get X3 (level 123). }}. | Definition | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | x3 | |
P : nat -> Prop. Elpi Command mode. Elpi Query lp:{{ coq.hints.add-mode {{:gref P }} "core" [mode-input], coq.hints.add-mode {{:gref P }} "core" [mode-ground], coq.hints.modes {{:gref P }} "core" M, std.assert! (M = [[mode-ground],[mode-input]]) "wrong modes" }}. Elpi Command pv. Elpi Accumulate lp:{{ main [trm (primit... | Axiom | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | P | |
times := plus. #[local] Hint Transparent times : core. Elpi Query lp:{{ {{ plus }} = global (const C1), coq.hints.opaque C1 "core" X1, std.assert!(X1 = @opaque!) "wrong opaque plus", {{ times }} = global (const C2), coq.hints.opaque C2 "core" X2, std.assert!(X2 = @transparent!) "wrong opaque times" }}. | Definition | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | times | |
x := 3. Elpi Query lp:{{ std.do! [ {{ x }} = global (const C1), coq.hints.opaque C1 "core" @opaque!, coq.hints.set-opaque C1 "core" @transparent!, coq.hints.opaque C1 "core" @transparent!, ] }}. #[local] Hint Opaque x : core. Elpi Query lp:{{ std.do! [coq.env.begin-module "xx" none, coq.env.end-module XX, coq.env.impor... | Definition | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | x | |
xeq T x y := x = y :> T. | Definition | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | xeq | |
xxx : xeq _ 0 1. Elpi Query lp:{{ coq.hints.add-resolve {{:gref xxx }} "core" 0 _. }}. Goal 0 = 1. Fail solve [trivial]. Abort. Create HintDb xxx. Elpi Query lp:{{ coq.hints.add-resolve {{:gref xxx }} "xxx" 0 {{ 0 = _ }} }}. Print HintDb xxx. (* I could not test the pattern, but it is printed Goal 0 = 1. solve [debug e... | Axiom | tests | [
"From elpi Require Import elpi.",
"From elpi.tests Require test_API.",
"From Corelib Require Import PrimFloat PrimInt63."
] | tests/test_API2.v | xxx | |
imp : forall T (x:T), x = x -> Prop. Arguments imp {_} [_] _ , [_] _ _ . Elpi Query lp:{{ coq.locate "imp" I, coq.arguments.implicit I [[maximal,implicit,explicit], [implicit,explicit,explicit]], (@global! => coq.arguments.set-implicit I [[]]), coq.arguments.implicit I [[explicit,explicit,explicit]] }}. | Axiom | tests | [
"From elpi Require Import elpi."
] | tests/test_API_arguments.v | imp | |
foo (T : Type) (x : T) := x. Arguments foo : clear implicits. Fail Check foo 3. Elpi Query lp:{{ @global! => coq.arguments.set-default-implicit {coq.locate "foo"} }}. Check foo 3. | Definition | tests | [
"From elpi Require Import elpi."
] | tests/test_API_arguments.v | foo | |
f T (x : T) := x = x. Elpi Query lp:{{ coq.arguments.set-name {coq.locate "f"} [some "S"], coq.arguments.name {coq.locate "f"} [some "S"], coq.arguments.set-implicit {coq.locate "f"} [[implicit]], coq.arguments.set-scope {coq.locate "f"} [["type"]], coq.arguments.scope {coq.locate "f"} [["type_scope"]] }}. About f. Che... | Definition | tests | [
"From elpi Require Import elpi."
] | tests/test_API_arguments.v | f |
Structured dataset from Coq-Elpi — Elpi-based extension language for Coq.
2,195 declarations extracted from Coq source files.
| Column | Type | Description |
|---|---|---|
| fact | string | Declaration body |
| type | string | Lemma, Definition, Theorem, etc. |
| library | string | Source module |
| imports | list | Required imports |
| filename | string | Source file path |
| symbolic_name | string | Identifier |