Debian Codegraph @

src/Rewriter/TestRules.v

raw
1 (** A version of [Rules.v] for testing *)
2 From Coq Require Import ZArith.
3 Require Import Crypto.Util.ListUtil Coq.Lists.List Crypto.Util.ListUtil.FoldBool.
4 Require Import Crypto.Util.ZRange.
5 Require Import Crypto.Util.ZRange.Operations.
6 Require Import Crypto.Util.ZUtil.Definitions.
7 Require Import Crypto.Util.ZUtil.Notations.
8 Require Import Crypto.Util.ZRange.
9 Require Import Crypto.Util.ZRange.Operations.
10 Require Import Crypto.Language.PreExtra.
11 Require Import Crypto.Util.LetIn.
12 Require Import Crypto.Util.Notations.
13 Import ListNotations. Local Open Scope bool_scope. Local Open Scope Z_scope.
14
15 Local Definition mymap {A B} := Eval cbv in @List.map A B.
16 Local Definition myapp {A} := Eval cbv in @List.app A.
17 Local Definition myflatten {A} := Eval cbv in List.fold_right myapp (@nil A).
18 Local Notation dont_do_again := (pair false) (only parsing).
19 Local Notation do_again := (pair true) (only parsing).
20
21 Local Notation "' x" := (ident.literal x).
22 Local Notation cstZ r := (ident.cast ('r%zrange)).
23 Local Notation cstZZ r1 r2 := (ident.cast2 ('(r1%zrange), '(r2%zrange))).
24 Local Notation "'plet' x := y 'in' z"
25 := (match y return _ with x => z end).
26
27 Local Notation dlet2_opp2 rv rc e
28 := (plet rc' := (-rc)%zrange in
29 plet cst' := cstZZ rv rc' in
30 plet cst1 := cstZ rv in
31 plet cst2 := cstZ rc in
32 plet cst2' := cstZ rc' in
33 (dlet vc := cst' e in
34 (cst1 (fst (cst' vc)), cst2 (-(cst2' (snd (cst' vc))))))).
35
36 Local Notation dlet2 rv rc e
37 := (dlet vc := cstZZ rv rc e in
38 (cstZ rv (fst (cstZZ rv rc vc)),
39 cstZ rc (snd (cstZZ rv rc vc)))).
40
41
42 Local Notation "x '\in' y" := (is_bounded_by_bool x (ZRange.normalize y) = true) : zrange_scope.
43 Local Notation "x ∈ y" := (is_bounded_by_bool x (ZRange.normalize y) = true) : zrange_scope.
44 Local Notation "x <= y" := (is_tighter_than_bool (ZRange.normalize x) y = true) : zrange_scope.
45 Local Notation litZZ x := (ident.literal (fst x), ident.literal (snd x)) (only parsing).
46 Local Notation n r := (ZRange.normalize r) (only parsing).
47
48 Definition test_rewrite_rulesT : list (bool * Prop)
49 := Eval cbv [myapp mymap myflatten] in
50 myflatten
51 [mymap
52 dont_do_again
53 [(forall A B x y, @fst A B (x, y) = x)
54 ; (forall A B x y, @snd A B (x, y) = y)
55 ; (forall x rx y ry rxy,
56 rx <> ry
57 -> cstZ rxy (cstZ rx x + cstZ ry y)
58 = cstZ rxy (cstZ rx x + cstZ ry y))
59 ]
60 ].