Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Blaisorblade
Created December 15, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blaisorblade/89a54d11413c2b1d0aca110028edaf98 to your computer and use it in GitHub Desktop.
Save Blaisorblade/89a54d11413c2b1d0aca110028edaf98 to your computer and use it in GitHub Desktop.
Require Import NArith ZArith PArith.
Ltac is_positive p :=
lazymatch p with
| xI ?pa => is_positive pa
| xO ?pa => is_positive pa
| xH => idtac
| _ => fail
end.
Ltac is_N n :=
lazymatch n with
| N0 => idtac
| Npos ?p => is_positive p
| _ => fail
end.
Open Scope N_scope.
(* Ltac is_N n := match n with | N0 => idtac | Npos ?p => is_positive p | _ => fail "Not constant" end. *)
Goal forall n : N, (42 + 13) + (n + 7) + (n + n) = 62 + 3 * n.
intros.
(* let n := constr:(0%N) in
let c := is_N n in idtac c. *)
match goal with
| |- context [?n + ?p] =>
idtac "n" n;
is_N n;
idtac "p" p
(* idtac res "n" n "p" p; *)
| _ => idtac "done"
end.
@Blaisorblade
Copy link
Author

output:

n (42 + 13 + (n + 7))
n (42 + 13)
n 42
p 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment