Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future-proof CompilersTestCases #1762

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/AbstractInterpretation/ZRangeProofs.v
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ Module Compilers.
: ZRange.type.option.is_bounded_by x v = true
-> type.related_hetero (fun t x v => ZRange.type.base.option.is_bounded_by x v = true) x v.
Proof. induction t; cbn in *; intuition congruence. Qed.

Lemma is_bounded_by_impl_eqv_refl t
(x : ZRange.type.option.interp t) (v : type.interp base.interp t)
: ZRange.type.option.is_bounded_by x v = true
-> v == v.
Proof. induction t; cbn; try reflexivity; try congruence. Qed.

Lemma andb_bool_for_each_lhs_of_arrow_is_bounded_by_impl_and_for_each_lhs_of_arrow_eqv_refl t
(x : type.for_each_lhs_of_arrow ZRange.type.option.interp t) (v : type.for_each_lhs_of_arrow (type.interp base.interp) t)
: type.andb_bool_for_each_lhs_of_arrow (@ZRange.type.option.is_bounded_by) x v = true
-> type.and_for_each_lhs_of_arrow (@type.eqv) v v.
Proof.
induction t; cbn; [ reflexivity | ].
rewrite Bool.andb_true_iff.
intros [H0 H1].
split; eauto using is_bounded_by_impl_eqv_refl.
Qed.
End option.
End type.

Expand Down Expand Up @@ -244,7 +261,7 @@ Module Compilers.
-- f_equal. assumption.
-- intros v H. apply IH2. assumption.
Qed.

Local Ltac handle_lt_le_t_step_fast :=
first [ match goal with
| [ H : (?a <= ?b)%Z, H' : (?b <= ?a)%Z |- _ ]
Expand Down
20 changes: 10 additions & 10 deletions src/CompilersTestCases.v
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,34 @@ Module testrewrite.
((\ x , expr_let y := ##5 in $$y + ($$y + (#ident.fst @ $$x + #ident.snd @ $$x)))
@ (##1, ##7))%expr).

Redirect "log" Eval cbv in partial.eval_with_bound partial.default_relax_zrange false (@ident.is_comment) false
Redirect "log" Eval cbv in partial.EvalWithBound partial.default_relax_zrange false (@ident.is_comment) false
(RewriteRules.RewriteNBE RewriteRules.default_opts (fun var =>
(\z , ((\ x , expr_let y := ##5 in $$y + ($$z + (#ident.fst @ $$x + #ident.snd @ $$x)))
@ (##1, ##7)))%expr) _)
@ (##1, ##7)))%expr))
(Datatypes.Some r[0~>100]%zrange, Datatypes.tt).
End testrewrite.
Module testpartial.
Import expr.
Import ident.

Redirect "log" Eval compute in partial.eval
(#ident.fst @ (expr_let x := ##10 in ($$x, $$x)))%expr.
Redirect "log" Eval compute in partial.Eval
(fun _ => #ident.fst @ (expr_let x := ##10 in ($$x, $$x)))%expr.

Notation "x + y" := (@expr.Ident base.type ident _ _ (ident.Z_add) @ x @ y)%expr : expr_scope.

Redirect "log" Eval compute in partial.eval
((\ x , expr_let y := ##5 in #ident.fst @ $$x + (#ident.fst @ $$x + ($$y + $$y)))
Redirect "log" Eval compute in partial.Eval
(fun _ => (\ x , expr_let y := ##5 in #ident.fst @ $$x + (#ident.fst @ $$x + ($$y + $$y)))
@ (##1, ##1))%expr.

Redirect "log" Eval compute in partial.eval
((\ x , expr_let y := ##5 in $$y + ($$y + (#ident.fst @ $$x + #ident.snd @ $$x)))
Redirect "log" Eval compute in partial.Eval
(fun _ => (\ x , expr_let y := ##5 in $$y + ($$y + (#ident.fst @ $$x + #ident.snd @ $$x)))
@ (##1, ##7))%expr.


Redirect "log" Eval cbv in partial.eval_with_bound
Redirect "log" Eval cbv in partial.EvalWithBound
partial.default_relax_zrange
false (@ident.is_comment) false
(\z , ((\ x , expr_let y := ##5 in $$y + ($$z + (#ident.fst @ $$x + #ident.snd @ $$x)))
(fun _ => \z , ((\ x , expr_let y := ##5 in $$y + ($$z + (#ident.fst @ $$x + #ident.snd @ $$x)))
@ (##1, ##7)))%expr
(Datatypes.Some r[0~>100]%zrange, Datatypes.tt).
End testpartial.
Expand Down
Loading