Debian Codegraph @

src/Rewriter/Passes/ToFancyWithCasts.v

raw
1 From Coq Require Import ZArith.
2 Require Import Crypto.Util.ZRange.
3 Require Import Rewriter.Language.Language.
4 Require Import Crypto.Language.API.
5 Require Import Rewriter.Language.Wf.
6 Require Import Crypto.Language.WfExtra.
7 Require Import Crypto.Rewriter.AllTacticsExtra.
8 Require Import Crypto.Rewriter.RulesProofs.
9
10 Module Compilers.
11 Import Language.Compilers.
12 Import Language.API.Compilers.
13 Import Language.Wf.Compilers.
14 Import Language.WfExtra.Compilers.
15 Import Rewriter.AllTacticsExtra.Compilers.RewriteRules.GoalType.
16 Import Rewriter.AllTactics.Compilers.RewriteRules.Tactic.
17 Import Compilers.Classes.
18
19 Module Import RewriteRules.
20 Section __.
21 Context (invert_low invert_high : Z (*log2wordmax*) -> Z -> @option Z)
22 (value_range flag_range : zrange)
23 (Hlow : forall s v v', invert_low s v = Some v' -> v = Z.land v' (2^(s/2)-1))
24 (Hhigh : forall s v v', invert_high s v = Some v' -> v = Z.shiftr v' (s/2)).
25
26 Definition VerifiedRewriterToFancyWithCasts : VerifiedRewriter_with_args false false true (@fancy_with_casts_rewrite_rules_proofs invert_low invert_high value_range flag_range Hlow Hhigh).
27 Proof using All. make_rewriter. Defined.
28
29 Definition default_opts := Eval hnf in @default_opts VerifiedRewriterToFancyWithCasts.
30 Let optsT := Eval hnf in optsT VerifiedRewriterToFancyWithCasts.
31
32 Definition RewriteToFancyWithCasts (opts : optsT) {t : API.type} : API.Expr t -> API.Expr t.
33 Proof using invert_low invert_high value_range flag_range.
34 let v := (eval hnf in (@Rewrite VerifiedRewriterToFancyWithCasts opts t)) in exact v.
35 Defined.
36
37 Lemma Wf_RewriteToFancyWithCasts opts {t} e (Hwf : Wf e) : Wf (@RewriteToFancyWithCasts opts t e).
38 Proof using All. now apply VerifiedRewriterToFancyWithCasts. Qed.
39
40 Lemma Interp_RewriteToFancyWithCasts opts {t} e (Hwf : Wf e) : API.Interp (@RewriteToFancyWithCasts opts t e) == API.Interp e.
41 Proof using All. now apply VerifiedRewriterToFancyWithCasts. Qed.
42 End __.
43 End RewriteRules.
44
45 Module Export Hints.
46 #[global]
47 Hint Resolve Wf_RewriteToFancyWithCasts : wf wf_extra.
48 #[global]
49 Hint Opaque RewriteToFancyWithCasts : wf wf_extra interp interp_extra rewrite.
50 #[global]
51 Hint Rewrite @Interp_RewriteToFancyWithCasts : interp interp_extra.
52 End Hints.
53 End Compilers.