-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImpureAlarmConfig.v
40 lines (34 loc) · 1.57 KB
/
ImpureAlarmConfig.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(* *****************************************************************)
(* *)
(* Verified polyhedral AST generation *)
(* *)
(* Nathanaël Courant, Inria Paris *)
(* *)
(* Copyright Inria. All rights reserved. This file is distributed *)
(* under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation, either version 2.1 *)
(* of the License, or (at your option) any later version. *)
(* *)
(* *****************************************************************)
Require Import Result.
Require Import Vpl.Impure Vpl.Debugging.
Require Import ImpureOperations.
Require Import Semantics.
Require Vpl.ImpureConfig.
Module CoreAlarmed := AlarmImpureMonad Vpl.ImpureConfig.Core.
Export CoreAlarmed.
Module Export ImpOps := ImpureOps CoreAlarmed.
Module Export IIS := IterImpureSemantics CoreAlarmed.
Definition res_to_alarm {A : Type} (d : A) (x : result A) : imp A :=
match x with
| Ok a => pure a
| Err s => alarm s (failwith INTERN s d)
end.
Lemma res_to_alarm_correct :
forall (A : Type) (d : A) (x : result A) (y : A),
mayReturn (res_to_alarm d x) y -> x = Ok y.
Proof.
intros A d x y. destruct x; simpl.
- intros H. f_equal. apply mayReturn_pure. auto.
- intros H. apply mayReturn_alarm in H. tauto.
Qed.