Debian Codegraph @

src/Util/SideConditions/RingPackage.v

raw
1 From Coq Require Import ZArith.
2 From Coq Require Import Ring_tac.
3 Require Import Crypto.Util.Prod.
4 Require Import Crypto.Util.SideConditions.CorePackages.
5 Require Export Crypto.Util.FixCoqMistakes.
6
7 Definition eq_by_Zring_prod_package (P : Prop) := P.
8
9 Ltac auto_split_prod_step_early special_ring_intros_tac :=
10 match goal with
11 | _ => progress hnf
12 | _ => progress special_ring_intros_tac ()
13 | [ H : prod _ _ |- _ ] => destruct H
14 | [ |- forall a, _ ] => let a := fresh in intro a; compute in a
15 end.
16
17 Ltac auto_split_prod_step special_ring_intros_tac :=
18 match goal with
19 | _ => auto_split_prod_step_early special_ring_intros_tac
20 | [ |- pair _ _ = pair _ _ ] => apply f_equal2
21 | [ |- @eq (prod _ _) _ _ ] => apply path_prod
22 end.
23
24 Ltac Zring_prod_eq_tac_gen special_ring_intros_tac :=
25 repeat auto_split_prod_step_early special_ring_intros_tac;
26 cbv -[Z.add Z.sub Z.mul Z.div Z.pow Z.opp Z.log2 Z.land Z.lor Z.log2_up Z.abs];
27 repeat match goal with
28 | _ => auto_split_prod_step special_ring_intros_tac
29 | [ |- @eq Z _ _ ] => ring
30 end.
31
32 Ltac default_ring_intros_tac _ := fail.
33
34 Ltac Zring_prod_eq_tac _ := Zring_prod_eq_tac_gen default_ring_intros_tac.
35
36 Ltac autosolve_gen_intros special_ring_intros_tac else_tac :=
37 lazymatch goal with
38 | [ |- eq_by_Zring_prod_package _ ]
39 => abstract Zring_prod_eq_tac_gen special_ring_intros_tac
40 | _ => else_tac ()
41 end.
42
43 Ltac autosolve else_tac := autosolve_gen_intros default_ring_intros_tac else_tac.