Skip to content

Commit 0b8356c

Browse files
authored
Merge pull request #55 from math-comp/verbose-attribute
#[verbose] attribute
2 parents d288261 + 59fb5b2 commit 0b8356c

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

examples/ring_examples.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Goal (a + b + c) ^+ 2 =
2323
a * a + b ^+ 2 + c * c + 2%:R * a * b + 2%:R * a * c + 2%:R * b * c.
2424
Proof. ring. Qed.
2525

26+
Goal (a + b + c) ^+ 2 =
27+
a * a + b ^+ 2 + c * c + 2%:R * a * b + 2%:R * a * c + 2%:R * b * c.
28+
Proof. (#[verbose] ring). Qed.
29+
2630
(* Using the _%:~R embedding from int to R : 2 is coerced to (Posz 2) : int *)
2731
Goal (a + b + c) ^+ 2 =
2832
a * a + b ^+ 2 + c * c + 2%:~R * a * b + 2%:~R * a * c + 2%:~R * b * c.

theories/common.elpi

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ quote.ring _ _ _ _ In _ _ _ :- coq.error "Unknown" {coq.term->string In}.
394394

395395
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396396

397+
pred if-verbose i:prop.
398+
if-verbose P :- get-option "verbose" tt, !, P.
399+
if-verbose _.
400+
397401
pred append-last-hyp-to-args i:sealed-goal, o:sealed-goal.
398402
append-last-hyp-to-args (nabla G) (nabla G1) :-
399403
pi x\ append-last-hyp-to-args (G x) (G1 x).
@@ -431,7 +435,10 @@ ring-reflection _ _ _ _ _ _ _ _ _ _ :-
431435
coq.ltac.fail 0 "Not a valid ring equation".
432436

433437
pred ring i:goal, o:list sealed-goal.
434-
ring (goal _ _ P _ Args as G) GS :- std.do! [
438+
ring (goal _ _ P _ Args as G) GS :-
439+
attributes A, !,
440+
coq.parse-attributes A [att "verbose" bool] Opts, !,
441+
Opts => std.do! [
435442
@ltacfail! 0 => std.assert-ok!
436443
(coq.unify-eq P {{ @eq lp:Ty lp:T1 lp:T2 }})
437444
"The goal is not an equation",
@@ -446,7 +453,7 @@ ring (goal _ _ P _ Args as G) GS :- std.do! [
446453
quote.ring Ring none Ring (x\ x) T1 RE1 PE1 VarMap,
447454
quote.ring Ring none Ring (x\ x) T2 RE2 PE2 VarMap
448455
) ReifTime,
449-
coq.say "Reification:" ReifTime "sec.",
456+
if-verbose (coq.say "Reification:" ReifTime "sec."),
450457
list-constant Ty VarMap VarMap',
451458
list-constant _ Lpe Lpe',
452459
std.assert-ok! (coq.typecheck Lpe' _) "Ill-typed term",
@@ -455,7 +462,7 @@ ring (goal _ _ P _ Args as G) GS :- std.do! [
455462
std.time (
456463
ring-reflection ComRing VarMap' Lpe' RE1 RE2 PE1 PE2 LpeProofs' G GS
457464
) ReflTime,
458-
coq.say "Reflection:" ReflTime "sec.",
465+
if-verbose (coq.say "Reflection:" ReflTime "sec."),
459466
].
460467

461468
pred field-reflection i:term, i:term, i:term, i:term, i:term, i:term,
@@ -468,7 +475,10 @@ field-reflection _ _ _ _ _ _ _ _ _ _ :-
468475
coq.ltac.fail 0 "Not a valid ring equation".
469476

470477
pred field i:goal, o:list sealed-goal.
471-
field (goal _ _ P _ Args as G) GS :- std.do! [
478+
field (goal _ _ P _ Args as G) GS :-
479+
attributes A, !,
480+
coq.parse-attributes A [att "verbose" bool] Opts, !,
481+
Opts => std.do! [
472482
@ltacfail! 0 => std.assert-ok!
473483
(coq.unify-eq P {{ @eq lp:Ty lp:T1 lp:T2 }})
474484
"The goal is not an equation",
@@ -484,7 +494,7 @@ field (goal _ _ P _ Args as G) GS :- std.do! [
484494
field-mode => quote.ring Ring (some Field) Ring (x\ x) T1 RE1 PE1 VarMap,
485495
field-mode => quote.ring Ring (some Field) Ring (x\ x) T2 RE2 PE2 VarMap
486496
) ReifTime,
487-
coq.say "Reification:" ReifTime "sec.",
497+
if-verbose (coq.say "Reification:" ReifTime "sec."),
488498
list-constant Ty VarMap VarMap',
489499
list-constant _ Lpe Lpe',
490500
std.assert-ok! (coq.typecheck Lpe' _) "Ill-typed term",
@@ -495,5 +505,5 @@ field (goal _ _ P _ Args as G) GS :- std.do! [
495505
(field-reflection NField VarMap' Lpe' RE1 RE2 PE1 PE2 LpeProofs' G GS)
496506
(field-reflection Field VarMap' Lpe' RE1 RE2 PE1 PE2 LpeProofs' G GS)
497507
) ReflTime,
498-
coq.say "Reflection:" ReflTime "sec.",
508+
if-verbose (coq.say "Reflection:" ReflTime "sec."),
499509
].

theories/ring.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ Elpi Typecheck.
704704

705705
Tactic Notation "ring" := elpi ring.
706706
Tactic Notation "ring" ":" ne_constr_list(L) := elpi ring ltac_term_list:(L).
707+
Tactic Notation "#[" attributes(A) "]" "ring" := ltac_attributes:(A) elpi ring.
708+
Tactic Notation "#[" attributes(A) "]" "ring" ":" ne_constr_list(L) :=
709+
ltac_attributes:(A) elpi ring ltac_term_list:(L).
707710

708711
Elpi Tactic field.
709712
Elpi Accumulate File "theories/common.elpi".
@@ -712,3 +715,7 @@ Elpi Typecheck.
712715

713716
Tactic Notation "field" := elpi field.
714717
Tactic Notation "field" ":" ne_constr_list(L) := elpi field ltac_term_list:(L).
718+
Tactic Notation "#[" attributes(A) "]" "field" :=
719+
ltac_attributes:(A) elpi field.
720+
Tactic Notation "#[" attributes(A) "]" "field" ":" ne_constr_list(L) :=
721+
ltac_attributes:(A) elpi field ltac_term_list:(L).

0 commit comments

Comments
 (0)