Skip to content

Commit

Permalink
Ncring_tac: don't use pairs to handle extensibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SkySkimmer committed Sep 5, 2024
1 parent 8e9dcc7 commit 8bf2ee4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
7 changes: 7 additions & 0 deletions doc/changelog/04-tactics/19501-ncring-tac-speed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- **Changed:**
`Ncring_tac.extra_reify` is expected to return `tt` on failure and
the reification result on success, instead of `(false, anything)` on failure
and `(true, result)` on success
(this only matters to users overriding it to extend the Ncring reification)
(`#19501 <https://github.com/coq/coq/pull/19501>`_,
by Gaëtan Gilbert).
10 changes: 5 additions & 5 deletions theories/nsatz/Nsatz.v
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ try (try apply Rsth;
Defined.

Ltac extra_reify term ::=
match term with
lazymatch term with
| IZR ?z =>
match isZcst z with
| true => open_constr:((true, PEc z))
| false => open_constr:((false,tt))
lazymatch isZcst z with
| true => open_constr:(PEc z)
| false => open_constr:(tt)
end
| _ => open_constr:((false,tt))
| _ => open_constr:(tt)
end.

Lemma R_one_zero: 1%R <> 0%R.
Expand Down
8 changes: 5 additions & 3 deletions theories/setoid_ring/Ncring_tac.v
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ Ltac close_varlist lvar :=
| _ => let _ := constr:(eq_refl : lvar = @nil _) in idtac
end.

Ltac extra_reify term := open_constr:((false,tt)).
(* extensibility: override to add ways to reify a term.
Return [tt] for terms which aren't handled (tt doesn't have type PExpr so is unambiguous) *)
Ltac extra_reify term := open_constr:(tt).

Ltac reify_term Tring lvar term :=
match open_constr:((Tring, term)) with
Expand Down Expand Up @@ -112,10 +114,10 @@ Ltac reify_term Tring lvar term :=
| _ =>
let extra := extra_reify term in
lazymatch extra with
| (false,_) =>
| tt =>
let n := reify_as_var lvar term in
open_constr:(PEX Z (Pos.of_succ_nat n))
| (true,?v) => v
| ?v => v
end
end.

Expand Down

0 comments on commit 8bf2ee4

Please sign in to comment.