Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- **Added:**
Ltac2 function ``Constr.is_prod_nd``
(`#22261 <https://github.com/rocq-prover/rocq/pull/22261>`_,
by Jason Gross).
11 changes: 11 additions & 0 deletions test-suite/ltac2/constr_is_prod_nd.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Require Import Ltac2.Ltac2.

Ltac2 Type exn ::= [ Regression_Test_Failure ].
Ltac2 check (b : bool) := if b then () else Control.throw Regression_Test_Failure.

Ltac2 Eval check (Constr.is_prod_nd constr:(nat -> nat)).
Ltac2 Eval check (Constr.is_prod_nd constr:(nat -> nat -> bool)).
Ltac2 Eval check (Bool.neg (Constr.is_prod_nd constr:(forall n : nat, n = n))).
Ltac2 Eval check (Constr.is_prod_nd constr:(forall _ : nat, nat)).
Ltac2 Eval check (Bool.neg (Constr.is_prod_nd constr:(fun n : nat => n))).
Ltac2 Eval check (Bool.neg (Constr.is_prod_nd constr:(0))).
8 changes: 8 additions & 0 deletions theories/Ltac2/Constr.v
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,11 @@ Ltac2 is_case(c: constr) :=
| Unsafe.Case _ _ _ _ _ => true
| _ => false
end.

(** [is_prod_nd c] returns [true] iff [c] is a non-dependent product,
i.e. a product whose codomain does not use the bound variable. *)
Ltac2 is_prod_nd(c: constr) :=
match Unsafe.kind c with
| Unsafe.Prod _ body => Unsafe.noccurn 1 body
| _ => false
end.
Loading