| 1 |
From Coq Require Import String. |
| 2 |
From Coq Require Import ZArith. |
| 3 |
From Coq Require Import List. |
| 4 |
Require Import Crypto.Util.ZRange. |
| 5 |
Require Import Crypto.Util.LetIn. |
| 6 |
Require Import Rewriter.Language.Language. |
| 7 |
Require Import Crypto.Language.API. |
| 8 |
Require Import Rewriter.Language.UnderLets. |
| 9 |
Require Import Crypto.AbstractInterpretation.AbstractInterpretation. |
| 10 |
Require Import Crypto.Rewriter.All. |
| 11 |
Require Import Crypto.MiscCompilerPasses. |
| 12 |
Require Import Crypto.Stringification.C. |
| 13 |
Import ListNotations. Local Open Scope Z_scope. |
| 14 |
|
| 15 |
Import Language.Compilers. |
| 16 |
Import UnderLets.Compilers. |
| 17 |
Import AbstractInterpretation.Compilers. |
| 18 |
Import Rewriter.All.Compilers. |
| 19 |
Import MiscCompilerPasses.Compilers. |
| 20 |
Import Stringification.C.Compilers. |
| 21 |
Import Language.API.Compilers. |
| 22 |
Local Coercion Z.of_nat : nat >-> Z. |
| 23 |
Import Compilers.API. |
| 24 |
|
| 25 |
Local Existing Instance AbstractInterpretation.default_Options. |
| 26 |
|
| 27 |
Local Notation "x + y" |
| 28 |
:= ((#ident.Z_add @ x @ y)%expr) |
| 29 |
: expr_scope. |
| 30 |
Local Notation "x * y" |
| 31 |
:= ((#ident.Z_mul @ x @ y)%expr) |
| 32 |
: expr_scope. |
| 33 |
Local Notation "x" := (expr.Var x) (only printing, at level 9) : expr_scope. |
| 34 |
Local Notation cstZ r := (#ident.Z_cast @ #(@ident.Literal base.type.zrange r%zrange))%expr. |
| 35 |
Local Notation cstZZ r1 r2 := (#ident.Z_cast2 @ (#(@ident.Literal base.type.zrange r1%zrange), #(@ident.Literal base.type.zrange r2%zrange)))%expr. |
| 36 |
|
| 37 |
Example test1 : True. |
| 38 |
Proof. |
| 39 |
let v := Reify ((fun x => 2^x) 255)%Z in |
| 40 |
pose v as E. |
| 41 |
vm_compute in E. |
| 42 |
pose (PartialEvaluate RewriteRules.default_opts E) as E'. |
| 43 |
vm_compute in E'. |
| 44 |
lazymatch (eval cbv delta [E'] in E') with |
| 45 |
| (fun var => expr.Ident (ident.Literal ?v)) => idtac |
| 46 |
end. |
| 47 |
constructor. |
| 48 |
Qed. |
| 49 |
Module testrewrite. |
| 50 |
Import expr. |
| 51 |
Import ident. |
| 52 |
|
| 53 |
Redirect "log" Eval compute in RewriteRules.RewriteNBE RewriteRules.default_opts (fun var => |
| 54 |
(#ident.fst @ (expr_let x := ##10 in ($$x, $$x)))%expr). |
| 55 |
|
| 56 |
Notation "x + y" := (@expr.Ident base.type ident _ _ ident.Z_add @ x @ y)%expr : expr_scope. |
| 57 |
|
| 58 |
Redirect "log" Eval compute in RewriteRules.RewriteNBE RewriteRules.default_opts (fun var => |
| 59 |
((\ x , expr_let y := ##5 in #ident.fst @ $$x + (#ident.fst @ $$x + ($$y + $$y))) |
| 60 |
@ (##1, ##1))%expr). |
| 61 |
|
| 62 |
Redirect "log" Eval compute in RewriteRules.RewriteNBE RewriteRules.default_opts (fun var => |
| 63 |
((\ x , expr_let y := ##5 in $$y + ($$y + (#ident.fst @ $$x + #ident.snd @ $$x))) |
| 64 |
@ (##1, ##7))%expr). |
| 65 |
|
| 66 |
Redirect "log" Eval cbv in partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) false |
| 67 |
(RewriteRules.RewriteNBE RewriteRules.default_opts (fun var => |
| 68 |
(\z , ((\ x , expr_let y := ##5 in $$y + ($$z + (#ident.fst @ $$x + #ident.snd @ $$x))) |
| 69 |
@ (##1, ##7)))%expr)) |
| 70 |
(Datatypes.Some r[0~>100]%zrange, Datatypes.tt). |
| 71 |
End testrewrite. |
| 72 |
Module testpartial. |
| 73 |
Import expr. |
| 74 |
Import ident. |
| 75 |
|
| 76 |
Redirect "log" Eval compute in partial.Eval |
| 77 |
(fun _ => #ident.fst @ (expr_let x := ##10 in ($$x, $$x)))%expr. |
| 78 |
|
| 79 |
Notation "x + y" := (@expr.Ident base.type ident _ _ (ident.Z_add) @ x @ y)%expr : expr_scope. |
| 80 |
|
| 81 |
Redirect "log" Eval compute in partial.Eval |
| 82 |
(fun _ => (\ x , expr_let y := ##5 in #ident.fst @ $$x + (#ident.fst @ $$x + ($$y + $$y))) |
| 83 |
@ (##1, ##1))%expr. |
| 84 |
|
| 85 |
Redirect "log" Eval compute in partial.Eval |
| 86 |
(fun _ => (\ x , expr_let y := ##5 in $$y + ($$y + (#ident.fst @ $$x + #ident.snd @ $$x))) |
| 87 |
@ (##1, ##7))%expr. |
| 88 |
|
| 89 |
|
| 90 |
Redirect "log" Eval cbv in partial.EvalWithBound |
| 91 |
partial.default_relax_zrange |
| 92 |
false (@ident.is_comment) false |
| 93 |
(fun _ => \z , ((\ x , expr_let y := ##5 in $$y + ($$z + (#ident.fst @ $$x + #ident.snd @ $$x))) |
| 94 |
@ (##1, ##7)))%expr |
| 95 |
(Datatypes.Some r[0~>100]%zrange, Datatypes.tt). |
| 96 |
End testpartial. |
| 97 |
|
| 98 |
Module test2. |
| 99 |
Example test2 : True. |
| 100 |
Proof. |
| 101 |
let v := Reify (fun y : Z |
| 102 |
=> (fun k : Z * Z -> Z * Z |
| 103 |
=> dlet_nd x := (y * y) in |
| 104 |
dlet_nd z := (x * x) in |
| 105 |
k (z, z)) |
| 106 |
(fun v => v)) in |
| 107 |
pose v as E. |
| 108 |
vm_compute in E. |
| 109 |
pose (partial.Eval E) as E'. |
| 110 |
vm_compute in E'. |
| 111 |
lazymatch (eval cbv delta [E'] in E') with |
| 112 |
| (fun var : type -> Type => |
| 113 |
(λ x : var _, |
| 114 |
expr_let x0 := ($$x * $$x) in |
| 115 |
expr_let x1 := ($$x0 * $$x0) in |
| 116 |
($$x1, $$x1))%expr) => idtac |
| 117 |
end. |
| 118 |
pose (partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) false E' (Some r[0~>10]%zrange, tt)) as E''. |
| 119 |
lazy in E''. |
| 120 |
lazymatch (eval cbv delta [E''] in E'') with |
| 121 |
| (fun var : type -> Type => |
| 122 |
(λ x : var _, |
| 123 |
expr_let y := (cstZ r[0 ~> 100]) @ (((cstZ r[0 ~> 10]) @ $$x) * ((cstZ r[0 ~> 10]) @ $$x)) in |
| 124 |
expr_let y0 := (cstZ r[0 ~> 10000]) @ (((cstZ r[0 ~> 100]) @ $$y) * ((cstZ r[0 ~> 100]) @ $$y)) in |
| 125 |
((cstZ r[0 ~> 10000]) @ $$y0, (cstZ r[0 ~> 10000]) @ $$y0))%expr) |
| 126 |
=> idtac |
| 127 |
end. |
| 128 |
constructor. |
| 129 |
Qed. |
| 130 |
End test2. |
| 131 |
Module test3. |
| 132 |
Example test3 : True. |
| 133 |
Proof. |
| 134 |
let v := Reify (fun y : Z |
| 135 |
=> dlet_nd x := dlet_nd x := (y * y) in |
| 136 |
(x * x) in |
| 137 |
dlet_nd z := dlet_nd z := (x * x) in |
| 138 |
(z * z) in |
| 139 |
(z * z)) in |
| 140 |
pose v as E. |
| 141 |
vm_compute in E. |
| 142 |
pose (partial.Eval E) as E'. |
| 143 |
vm_compute in E'. |
| 144 |
lazymatch (eval cbv delta [E'] in E') with |
| 145 |
| (fun var : type -> Type => |
| 146 |
(λ x : var _, |
| 147 |
expr_let x0 := $$x * $$x in |
| 148 |
expr_let x1 := $$x0 * $$x0 in |
| 149 |
expr_let x2 := $$x1 * $$x1 in |
| 150 |
expr_let x3 := $$x2 * $$x2 in |
| 151 |
$$x3 * $$x3)%expr) |
| 152 |
=> idtac |
| 153 |
end. |
| 154 |
pose (partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) false E' (Some r[0~>10]%zrange, tt)) as E'''. |
| 155 |
lazy in E'''. |
| 156 |
lazymatch (eval cbv delta [E'''] in E''') with |
| 157 |
| (fun var : type -> Type => |
| 158 |
(λ x : var _, |
| 159 |
expr_let y := (cstZ r[0 ~> 100]) @ (((cstZ r[0 ~> 10]) @ $$x) * ((cstZ r[0 ~> 10]) @ $$x)) in |
| 160 |
expr_let y0 := (cstZ r[0 ~> 10000]) @ (((cstZ r[0 ~> 100]) @ $$y) * ((cstZ r[0 ~> 100]) @ $$y)) in |
| 161 |
expr_let y1 := (cstZ r[0 ~> 100000000]) @ (((cstZ r[0 ~> 10000]) @ $$y0) * ((cstZ r[0 ~> 10000]) @ $$y0)) in |
| 162 |
expr_let y2 := (cstZ r[0 ~> 10000000000000000]) @ (((cstZ r[0 ~> 100000000]) @ $$y1) * ((cstZ r[0 ~> 100000000]) @ $$y1)) in |
| 163 |
(cstZ r[0 ~> 100000000000000000000000000000000]) @ (((cstZ r[0 ~> 10000000000000000]) @ $$y2) * ((cstZ r[0 ~> 10000000000000000]) @ $$y2)))%expr) |
| 164 |
=> idtac |
| 165 |
end. |
| 166 |
constructor. |
| 167 |
Qed. |
| 168 |
End test3. |
| 169 |
Module test3point5. |
| 170 |
Example test3point5 : True. |
| 171 |
Proof. |
| 172 |
let v := Reify (fun y : (list Z) => List.nth_default (-1) y 0) in |
| 173 |
pose v as E. |
| 174 |
vm_compute in E. |
| 175 |
pose (partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) false E (Some [Some r[0~>10]%zrange], tt)) as E'. |
| 176 |
lazy in E'. |
| 177 |
clear E. |
| 178 |
lazymatch (eval cbv delta [E'] in E') with |
| 179 |
| (fun var : type -> Type => |
| 180 |
(λ x : var _, |
| 181 |
(cstZ r[0 ~> 10]) @ (#ident.List_nth_default @ #(ident.Literal (0)%Z) @ $$x @ #(ident.Literal 0%nat)))%expr) |
| 182 |
=> idtac |
| 183 |
end. |
| 184 |
constructor. |
| 185 |
Qed. |
| 186 |
End test3point5. |
| 187 |
Module test4. |
| 188 |
Example test4 : True. |
| 189 |
Proof. |
| 190 |
let v := Reify (fun y : (list Z * list Z) |
| 191 |
=> dlet_nd x := List.nth_default (-1) (fst y) 0 in |
| 192 |
dlet_nd z := List.nth_default (-1) (snd y) 0 in |
| 193 |
dlet_nd xz := (x * z) in |
| 194 |
(xz :: xz :: nil)) in |
| 195 |
pose v as E. |
| 196 |
vm_compute in E. |
| 197 |
pose (partial.Eval E) as E'. |
| 198 |
lazy in E'. |
| 199 |
clear E. |
| 200 |
pose (Some [Some r[0~>10]%zrange],Some [Some r[0~>10]%zrange], Datatypes.tt) as bound. |
| 201 |
pose (partial.EtaExpandWithListInfoFromBound E' bound) as E''. |
| 202 |
lazy in E''. |
| 203 |
clear E'. |
| 204 |
pose (PartialEvaluate RewriteRules.default_opts E'') as E'''. |
| 205 |
lazy in E'''. |
| 206 |
pose (partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) false E''' bound) as E''''. |
| 207 |
lazy in E''''. |
| 208 |
clear E'' E'''. |
| 209 |
lazymatch (eval cbv delta [E''''] in E'''') with |
| 210 |
| (fun var : type -> Type => |
| 211 |
(λ x : var _, |
| 212 |
expr_let y := (cstZ r[0 ~> 10]) @ |
| 213 |
(#ident.List_nth_default @ #(ident.Literal (0)%Z) @ (#ident.fst @ $$x) @ #(ident.Literal 0%nat)) in |
| 214 |
expr_let y0 := (cstZ r[0 ~> 10]) @ |
| 215 |
(#ident.List_nth_default @ #(ident.Literal (0)%Z) @ (#ident.snd @ $$x) @ #(ident.Literal 0%nat)) in |
| 216 |
expr_let y1 := (cstZ r[0 ~> 100]) @ (((cstZ r[0 ~> 10]) @ $$y) * ((cstZ r[0 ~> 10]) @ $$y0)) in |
| 217 |
(cstZ r[0 ~> 100]) @ $$y1 :: (cstZ r[0 ~> 100]) @ $$y1 :: [])%expr) |
| 218 |
=> idtac |
| 219 |
end. |
| 220 |
constructor. |
| 221 |
Qed. |
| 222 |
End test4. |
| 223 |
Module test5. |
| 224 |
Example test5 : True. |
| 225 |
Proof. |
| 226 |
let v := Reify (fun y : (Z * Z) |
| 227 |
=> dlet_nd x := (13 * (fst y * snd y)) in |
| 228 |
x) in |
| 229 |
pose v as E. |
| 230 |
vm_compute in E. |
| 231 |
pose (RewriteRules.RewriteArith (2^8) RewriteRules.default_opts (partial.Eval E)) as E'. |
| 232 |
lazy in E'. |
| 233 |
clear E. |
| 234 |
lazymatch (eval cbv delta [E'] in E') with |
| 235 |
| (fun var => |
| 236 |
expr.Abs (fun v |
| 237 |
=> (expr_let v0 := (#ident.Z_mul @ (#ident.fst @ $$v) @ (#ident.Z_mul @ (#ident.snd @ $$v) @ #(ident.Literal 13))) in |
| 238 |
$$v0)%expr)) |
| 239 |
=> idtac |
| 240 |
end. |
| 241 |
constructor. |
| 242 |
Qed. |
| 243 |
|
| 244 |
Example test5_2 : True. |
| 245 |
Proof. |
| 246 |
let v := Reify (fun y : (Z * Z) |
| 247 |
=> dlet_nd x := (2 * (19 * (fst y * snd y))) in |
| 248 |
x) in |
| 249 |
pose v as E. |
| 250 |
vm_compute in E. |
| 251 |
pose (RewriteRules.RewriteArith (2^8) RewriteRules.default_opts (partial.Eval E)) as E'. |
| 252 |
lazy in E'. |
| 253 |
clear E. |
| 254 |
lazymatch (eval cbv delta [E'] in E') with |
| 255 |
| (fun var => |
| 256 |
expr.Abs (fun v |
| 257 |
=> (expr_let v0 := (#ident.Z_mul @ (#ident.fst @ $$v) @ (#ident.Z_mul @ (#ident.snd @ $$v) @ (#ident.Z_mul @ #(ident.Literal 2) @ #(ident.Literal 19)))) in |
| 258 |
$$v0)%expr)) |
| 259 |
=> idtac |
| 260 |
end. |
| 261 |
constructor. |
| 262 |
Qed. |
| 263 |
End test5. |
| 264 |
Module test6. |
| 265 |
(* check for no dead code with if *) |
| 266 |
Example test6 : True. |
| 267 |
Proof. |
| 268 |
let v := Reify (fun y : Z |
| 269 |
=> if 0 =? 1 |
| 270 |
then dlet_nd x := (y * y) in |
| 271 |
x |
| 272 |
else y) in |
| 273 |
pose v as E. |
| 274 |
vm_compute in E. |
| 275 |
pose (PartialEvaluate RewriteRules.default_opts E) as E''. |
| 276 |
lazy in E''. |
| 277 |
lazymatch eval cbv delta [E''] in E'' with |
| 278 |
| fun var : type -> Type => (λ x : var _, $$x)%expr |
| 279 |
=> idtac |
| 280 |
end. |
| 281 |
exact I. |
| 282 |
Qed. |
| 283 |
End test6. |
| 284 |
Module test7. |
| 285 |
Example test7 : True. |
| 286 |
Proof. |
| 287 |
let v := Reify (fun y : Z |
| 288 |
=> dlet_nd x := y + y in |
| 289 |
dlet_nd z := x in |
| 290 |
dlet_nd z' := z in |
| 291 |
dlet_nd z'' := z in |
| 292 |
z'' + z'') in |
| 293 |
pose v as E. |
| 294 |
vm_compute in E. |
| 295 |
pose (Subst01.Subst01 ident.is_comment (DeadCodeElimination.EliminateDead ident.is_comment E)) as E''. |
| 296 |
lazy in E''. |
| 297 |
lazymatch eval cbv delta [E''] in E'' with |
| 298 |
| fun var : type -> Type => (λ x : var _, expr_let v0 := $$x + $$x in $$v0 + $$v0)%expr |
| 299 |
=> idtac |
| 300 |
end. |
| 301 |
exact I. |
| 302 |
Qed. |
| 303 |
End test7. |
| 304 |
Module test8. |
| 305 |
Example test8 : True. |
| 306 |
Proof. |
| 307 |
let v := Reify (fun y : Z |
| 308 |
=> dlet_nd x := y + y in |
| 309 |
dlet_nd z := x in |
| 310 |
dlet_nd z' := z in |
| 311 |
dlet_nd z'' := z in |
| 312 |
z'' + z'') in |
| 313 |
pose v as E. |
| 314 |
vm_compute in E. |
| 315 |
pose (GeneralizeVar.GeneralizeVar (E _)) as E''. |
| 316 |
lazy in E''. |
| 317 |
unify E E''. |
| 318 |
exact I. |
| 319 |
Qed. |
| 320 |
End test8. |
| 321 |
Module test9. |
| 322 |
Example test9 : True. |
| 323 |
Proof. |
| 324 |
let v := Reify (fun y : list Z => (hd 0%Z y, tl y)) in |
| 325 |
pose v as E. |
| 326 |
vm_compute in E. |
| 327 |
pose (PartialEvaluate RewriteRules.default_opts E) as E'. |
| 328 |
lazy in E'. |
| 329 |
clear E. |
| 330 |
lazymatch (eval cbv delta [E'] in E') with |
| 331 |
| (fun var |
| 332 |
=> (λ x, |
| 333 |
(#ident.list_case |
| 334 |
@ (λ _, #(ident.Literal 0%Z)) |
| 335 |
@ (λ x0 _, $$x0) |
| 336 |
@ $$x, |
| 337 |
#ident.list_case |
| 338 |
@ (λ _, #ident.nil) |
| 339 |
@ (λ _ x1, $$x1) |
| 340 |
@ $$x))%expr) |
| 341 |
=> idtac |
| 342 |
end. |
| 343 |
exact I. |
| 344 |
Qed. |
| 345 |
End test9. |
| 346 |
(* |
| 347 |
Module test10. |
| 348 |
Example test10 : True. |
| 349 |
Proof. |
| 350 |
let v := Reify (fun (f : Z -> Z -> Z) x y => f (x + y) (x * y))%Z in |
| 351 |
pose v as E. |
| 352 |
vm_compute in E. |
| 353 |
pose (Uncurry.expr.Uncurry (partial.Eval true (canonicalize_list_recursion E))) as E'. |
| 354 |
lazy in E'. |
| 355 |
clear E. |
| 356 |
lazymatch (eval cbv delta [E'] in E') with |
| 357 |
| (fun var => |
| 358 |
(λ v, |
| 359 |
ident.fst @@@ $$v @ |
| 360 |
(ident.fst @@@ (ident.snd @@@ $$v) + ident.snd @@@ (ident.snd @@@ $$v)) @ |
| 361 |
(ident.fst @@@ (ident.snd @@@ $$v) * ident.snd @@@ (ident.snd @@@ $$v)))%expr) |
| 362 |
=> idtac |
| 363 |
end. |
| 364 |
constructor. |
| 365 |
Qed. |
| 366 |
End test10. |
| 367 |
*) |
| 368 |
(* |
| 369 |
Module test11. |
| 370 |
Example test11 : True. |
| 371 |
Proof. |
| 372 |
let v := Reify (fun x y => (fun f a b => f a b) (fun a b => a + b) (x + y) (x * y))%Z in |
| 373 |
pose v as E. |
| 374 |
vm_compute in E. |
| 375 |
pose (Uncurry.expr.Uncurry (partial.Eval true (canonicalize_list_recursion E))) as E'. |
| 376 |
lazy in E'. |
| 377 |
clear E. |
| 378 |
lazymatch (eval cbv delta [E'] in E') with |
| 379 |
| (fun var => |
| 380 |
(λ x, |
| 381 |
ident.fst @@@ $$x + ident.snd @@@ $$x + ident.fst @@@ $$x * ident.snd @@@ $$x)%expr) |
| 382 |
=> idtac |
| 383 |
end. |
| 384 |
constructor. |
| 385 |
Qed. |
| 386 |
End test11. |
| 387 |
*) |
| 388 |
Module test12. |
| 389 |
Example test12 : True. |
| 390 |
Proof. |
| 391 |
let v := Reify (fun y : list Z => repeat y 2) in |
| 392 |
pose v as E. |
| 393 |
vm_compute in E. |
| 394 |
pose (Some (repeat (@None zrange) 3), Datatypes.tt) as bound. |
| 395 |
pose (PartialEvaluate RewriteRules.default_opts (partial.EtaExpandWithListInfoFromBound E bound)) as E'. |
| 396 |
lazy in E'. |
| 397 |
clear E. |
| 398 |
lazymatch (eval cbv delta [E'] in E') with |
| 399 |
| (fun var |
| 400 |
=> (λ x, [ [ $$x[[0]] ; $$x[[1]]; $$x[[2]] ] ; [ $$x[[0]] ; $$x[[1]]; $$x[[2]] ] ])%expr) |
| 401 |
=> idtac |
| 402 |
end. |
| 403 |
exact I. |
| 404 |
Qed. |
| 405 |
End test12. |
| 406 |
Module test13. |
| 407 |
Example test13 : True. |
| 408 |
Proof. |
| 409 |
let v0 := constr:(nat_rect (fun _ => nat -> nat) (fun v => v) (fun n' rec v => (n' + rec (S v))%nat) 3 0%nat) in |
| 410 |
let v := Reify v0 in |
| 411 |
pose v as E; |
| 412 |
pose v0 as exp. |
| 413 |
vm_compute in E. |
| 414 |
vm_compute in exp. |
| 415 |
pose (PartialEvaluate RewriteRules.default_opts E) as E'. |
| 416 |
vm_compute in E'. |
| 417 |
clear E. |
| 418 |
let r := Reify exp in |
| 419 |
unify r E'. |
| 420 |
exact I. |
| 421 |
Qed. |
| 422 |
End test13. |
| 423 |
Module test14. |
| 424 |
Import PreExtra. |
| 425 |
Local Open Scope string_scope. |
| 426 |
Example test14 : True. |
| 427 |
Proof. |
| 428 |
let v := Reify (fun y : Z |
| 429 |
=> dlet_nd x := y + y in |
| 430 |
dlet_nd z := y + y in |
| 431 |
dlet_nd w := y + y in |
| 432 |
dlet_nd v := y + y in |
| 433 |
dlet_nd __ := ident.comment ("note", (x, x, z, z)) in |
| 434 |
dlet_nd __ := ident.comment_no_keep ("note", (w, w, v, v)) in |
| 435 |
y) in |
| 436 |
pose v as E. |
| 437 |
vm_compute in E. |
| 438 |
pose (Subst01.Subst01 ident.is_comment (DeadCodeElimination.EliminateDead ident.is_comment E)) as E''. |
| 439 |
lazy in E''. |
| 440 |
pose (PartialEvaluate RewriteRules.default_opts E'') as E'''. |
| 441 |
vm_compute in E'''. |
| 442 |
pose (partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) true E''' (Some r[0~>1]%zrange, tt)) as E''''. |
| 443 |
lazy in E''''. |
| 444 |
unify E E''. |
| 445 |
unify E'' E'''. |
| 446 |
lazymatch (eval cbv [E''''] in E'''') with |
| 447 |
| fun var : type -> Type => |
| 448 |
(λ x : var (type.base (base.type.type_base Compilers.Z)), |
| 449 |
expr_let v := cstZ r[0 ~> 2] @ |
| 450 |
(cstZ r[0 ~> 1] @ $$x + cstZ r[0 ~> 1] @ $$x) in |
| 451 |
expr_let v0 := cstZ r[0 ~> 2] @ |
| 452 |
(cstZ r[0 ~> 1] @ $$x + cstZ r[0 ~> 1] @ $$x) in |
| 453 |
expr_let v1 := cstZ r[0 ~> 2] @ |
| 454 |
(cstZ r[0 ~> 1] @ $$x + cstZ r[0 ~> 1] @ $$x) in |
| 455 |
expr_let v2 := cstZ r[0 ~> 2] @ |
| 456 |
(cstZ r[0 ~> 1] @ $$x + cstZ r[0 ~> 1] @ $$x) in |
| 457 |
expr_let _ := #Compilers.ident_comment @ (###_, ($$v, $$v, $$v0, $$v0)) in |
| 458 |
expr_let _ := #Compilers.ident_comment_no_keep @ |
| 459 |
(###_, ($$v1, $$v1, $$v2, $$v2)) in |
| 460 |
cstZ r[0 ~> 1] @ $$x)%expr |
| 461 |
=> idtac |
| 462 |
end. |
| 463 |
exact I. |
| 464 |
Qed. |
| 465 |
End test14. |