statement
stringlengths
6
506
proof
stringlengths
0
2.66k
type
stringclasses
17 values
symbolic_name
stringlengths
1
55
library
stringclasses
5 values
filename
stringclasses
22 values
imports
listlengths
2
12
deps
listlengths
0
20
docstring
stringlengths
0
1.35k
source_url
stringclasses
1 value
commit
stringclasses
1 value
interp i
:= (state (semantics i)).
Notation
interp
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "semantics" ]
A term of type [impure a] describes an impure computation expected to return a term of type [a]. Interpreting this term means actually realizing the computation and producing the result. This requires to provide an operational semantics for the interfaces used by the computation. Some operational sem...
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
interface_to_state {i} : i ~> interp i
:= fun a e => mkState (fun sem => run_effect sem e).
Definition
interface_to_state
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "interp", "run_effect" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
to_state {i} : impure i ~> state (semantics i)
:= impure_lift interface_to_state.
Definition
to_state
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "impure", "impure_lift", "interface_to_state", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_impure {i a} (sem : semantics i) (p : impure i a) : a * semantics i
:= runState (to_state p) sem.
Definition
run_impure
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "impure", "semantics", "to_state" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_impure {i a} (sem : semantics i) (p : impure i a) : a
:= fst (run_impure sem p).
Definition
eval_impure
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "impure", "run_impure", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_impure {i a} (sem : semantics i) (p : impure i a) : semantics i
:= snd (run_impure sem p).
Definition
exec_impure
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "impure", "run_impure", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
with_semantics {ix j α} (sem : semantics j) (p : impure (ix + j) α) : impure ix α
:= match p with | local x => local x | request_then (in_right e) f => let (res, next) := run_effect sem e in with_semantics next (f res) | request_then (in_left e) f => request_then e (fun x => with_semantics sem (f x)) end.
Fixpoint
with_semantics
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "impure", "run_effect", "semantics" ]
* In-place Primitives Handling
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
with_store {ix s a} (x : s) (p : impure (ix + STORE s) a) : impure ix a
:= with_semantics (store x) p.
Definition
with_store
Core
theories/Core/Semantics.v
[ "Coq", "Program", "Setoid", "Morphisms", "ExtLib", "Monad", "StateMonad", "FreeSpec.Core", "Interface", "Impure" ]
[ "STORE", "impure", "store", "with_semantics" ]
We provide [with_store], a helper function to locally provide a mutable variable.
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
compliant_semantics `{MayProvide ix i} `(c : contract i Ω) : Ω -> semantics ix -> Prop
:= | compliant_semantics_rec (sem : semantics ix) (ω : Ω) (o_callee : forall {α} (e : ix α), gen_caller_obligation c ω e -> gen_callee_obligation c ω e (eval_effect sem e)) (next : forall {α} (e : ix α), gen_caller_obligation c ω e -> compliant_semantics c (gen_witness_update c ω e (...
CoInductive
compliant_semantics
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "MayProvide", "contract", "eval_effect", "exec_effect", "gen_callee_obligation", "gen_caller_obligation", "gen_witness_update", "semantics" ]
Given a semantics [sem], and a witness [ω] if [sem] computes results which satisfies [c] callee obligations for effects which satisfy [c] caller obligations and if the resulting semantics produces after interpreting [e] complies to [c] in accordance to [ω'], where [ω'] is the new witness state after [e]...
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
store_complies_to_store_specs {s} (st : s) : compliant_semantics (store_specs s) st (store st).
Proof. revert st; cofix compliant_semantics_rec; intros st. constructor. + intros a [| st'] _. ++ now constructor. ++ now constructor. + intros a e req. cbn. replace (exec_effect (store st) e) with (store (store_update s st a e (eval_effect (store st) e))) by now destruct e as [| st'...
Lemma
store_complies_to_store_specs
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "compliant_semantics", "eval_effect", "exec_effect", "store", "store_specs", "store_update" ]
Proving that semantics obtained from the [store] function are compliant with [store_specs] is relatively simple.
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
compliant_semantics_caller_obligation_callee_obligation `{MayProvide ix i} `(c : contract i Ω) (ω : Ω) `(e : ix α) (o_caller : gen_caller_obligation c ω e) (sem : semantics ix) (comp : compliant_semantics c ω sem) : gen_callee_obligation c ω e (eval_effect sem e).
Proof. inversion comp; ssubst. now apply o_callee. Qed.
Lemma
compliant_semantics_caller_obligation_callee_obligation
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "MayProvide", "compliant_semantics", "contract", "eval_effect", "gen_callee_obligation", "gen_caller_obligation", "semantics", "ssubst" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
compliant_semantics_caller_obligation_compliant `{MayProvide ix i} {Ω α} (c : contract i Ω) (ω : Ω) (e : ix α) (o_caller : gen_caller_obligation c ω e) (sem : semantics ix) (comp : compliant_semantics c ω sem) : compliant_semantics c (gen_witness_update c ω e (eval_effect sem e)) (exec_effect sem e).
Proof. inversion comp; ssubst. now apply next. Qed.
Lemma
compliant_semantics_caller_obligation_compliant
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "MayProvide", "compliant_semantics", "contract", "eval_effect", "exec_effect", "gen_caller_obligation", "gen_witness_update", "semantics", "ssubst" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
no_contract_compliant_semantics `{MayProvide ix i} (sem : semantics ix) (u : unit) : compliant_semantics (no_contract i) u sem.
Proof. revert sem. cofix no_contract_compliant_semantics; intros sem. constructor. + intros α e req. unfold gen_caller_obligation, gen_callee_obligation. destruct proj_p; constructor. + intros α e req. unfold gen_witness_update. destruct (proj_p e); [ apply no_contract_compliant_semantics | au...
Lemma
no_contract_compliant_semantics
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "MayProvide", "compliant_semantics", "gen_callee_obligation", "gen_caller_obligation", "gen_witness_update", "no_contract", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
semantics_eq {i} : semantics i -> semantics i -> Prop
:= | semantics_eq_rec (sem sem' : semantics i) (res_eq : forall {a} (e : i a), eval_effect sem e = eval_effect sem' e) (next_eq : forall {a} (e : i a), semantics_eq (exec_effect sem e) (exec_effect sem' e)) : semantics_eq sem sem'.
CoInductive
semantics_eq
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "exec_effect", "semantics" ]
We say two semantics are equivalent when they produce equivalent outputs given the same primitive.
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
semantics_Equivalence (i : interface) : Equivalence (@semantics_eq i).
Next Obligation. cofix semantics_eq_refl. intros sem. constructor; intros α e. + reflexivity. + apply semantics_eq_refl. Qed.
Instance
semantics_Equivalence
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "interface", "semantics_eq" ]
We prove [semantics_eq] is indeed an equivalence.
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_effect_eq `(x : α * semantics i) (y : α * semantics i) : Prop
:= fst x = fst y /\ (snd x === snd y)%semantics.
Definition
run_effect_eq
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "semantics" ]
** Interpretation Results
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_effect_Equivalence a i : @Equivalence (a * semantics i) run_effect_eq.
Next Obligation. intros [x next]; now split. Qed.
Instance
run_effect_Equivalence
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "run_effect_eq", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
fst_Proper i α : Proper (run_effect_eq ==> eq) (@fst α (semantics i)).
Next Obligation. add_morphism_tactic. intros [x next] [y next'] [equ1 equ2]. apply equ1. Qed.
Instance
fst_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "run_effect_eq", "semantics" ]
** Proper Instances
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
snd_Proper i α : Proper (run_effect_eq ==> semantics_eq) (@snd α (semantics i)).
Next Obligation. add_morphism_tactic. intros [x next] [y next'] [equ1 equ2]. apply equ2. Qed.
Instance
snd_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "run_effect_eq", "semantics", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
prod_Proper i α : Proper (eq ==> semantics_eq ==> run_effect_eq) (@pair α (semantics i)).
Next Obligation. add_morphism_tactic. intros x sem sem' equ. split. + reflexivity. + apply equ. Qed.
Instance
prod_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "run_effect_eq", "semantics", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_effect_Proper i α : Proper (semantics_eq ==> eq ==> run_effect_eq) (@run_effect i α).
Proof. add_morphism_tactic. intros sem sem' equ e. rewrite run_effect_equation. inversion equ; subst. split. + apply res_eq. + apply next_eq. Qed.
Instance
run_effect_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "run_effect", "run_effect_eq", "run_effect_equation", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_effect_Proper i α : Proper (semantics_eq ==> eq ==> eq) (@eval_effect i α).
Next Obligation. add_morphism_tactic. intros o o' equ e. unfold eval_effect. now rewrite equ. Qed.
Instance
eval_effect_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_effect_Proper i α : Proper (semantics_eq ==> eq ==> semantics_eq) (@exec_effect i α).
Next Obligation. add_morphism_tactic. intros o o' equ e. unfold exec_effect. now rewrite equ. Qed.
Instance
exec_effect_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "exec_effect", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_semprod_in_left_eq `(semi : semantics i) `(semj : semantics j) `(e : i α) : eval_effect (semi * semj) (in_left e) = eval_effect semi e.
Proof. unfold eval_effect; cbn. destruct semi as [semi]. cbn. now destruct (semi α e). Qed.
Remark
eval_semprod_in_left_eq
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_semprod_in_right_eq `(semi : semantics i) `(semj : semantics j) `(e : j α) : eval_effect (semi * semj) (in_right e) = eval_effect semj e.
Proof. unfold eval_effect; cbn. destruct semj as [semj]. cbn. now destruct (semj α e). Qed.
Remark
eval_semprod_in_right_eq
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_semprod_in_left_eq `(semi : semantics i) `(semj : semantics j) `(e : i α) : exec_effect (semi * semj) (in_left e) = (semprod (exec_effect semi e) semj).
Proof. unfold exec_effect; cbn. destruct semi as [semi]. cbn. now destruct (semi _ e). Qed.
Remark
exec_semprod_in_left_eq
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "exec_effect", "semantics", "semprod" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_semprod_in_right_eq `(semi : semantics i) `(semj : semantics j) `(e : j α) : exec_effect (semi * semj) (in_right e) = (semprod semi (exec_effect semj e)).
Proof. unfold exec_effect; cbn. destruct semj as [semj]. cbn. now destruct (semj _ e). Qed.
Remark
exec_semprod_in_right_eq
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "exec_effect", "semantics", "semprod" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
semprod_Proper i j : Proper (semantics_eq ==> semantics_eq ==> semantics_eq) (@semprod i j).
Next Obligation. add_morphism_tactic. cofix semprod_Proper. intros semi semi' equi semj semj' equj. constructor; intros α e; destruct e. + repeat rewrite eval_semprod_in_left_eq. now inversion equi. + repeat rewrite eval_semprod_in_right_eq. now inversion equj. + repeat rewrite exec_semprod_in_lef...
Instance
semprod_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_semprod_in_left_eq", "eval_semprod_in_right_eq", "exec_semprod_in_left_eq", "exec_semprod_in_right_eq", "repeat", "semantics_eq", "semprod" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
compliant_semantics_Proper `{MayProvide ix i} `(c : contract i Ω) : Proper (eq ==> semantics_eq ==> Basics.impl) (compliant_semantics c).
Next Obligation. add_morphism_tactic. unfold Basics.impl. cofix proper. intros ω sem sem' equ comp. inversion equ; subst. inversion comp; subst. constructor; intros a e pre. + rewrite <- res_eq. now apply o_callee. + specialize next_eq with a e. eapply proper. exact next_eq. rewrite <-...
Instance
compliant_semantics_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "MayProvide", "compliant_semantics", "contract", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_impure_equation {i a} (sem : semantics i) (p : impure i a) : run_impure sem p = (eval_impure sem p, exec_impure sem p).
Proof. unfold eval_impure, exec_impure. destruct run_impure; reflexivity. Qed.
Lemma
run_impure_equation
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_impure", "exec_impure", "impure", "run_impure", "semantics" ]
We provide several lemmas and the necessary [Proper] instances to use these functions in conjunction with [semantics_equiv] and [impure_equiv].
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_impure_request_then_assoc {i a b} (sem : semantics i) (e : i a) (f : a -> impure i b) : run_impure sem (request_then e f) = run_impure (exec_effect sem e) (f (eval_effect sem e)).
Proof. cbn; now rewrite run_effect_equation. Qed.
Lemma
run_impure_request_then_assoc
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "exec_effect", "impure", "run_effect_equation", "run_impure", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_impure_request_then_assoc {i a b} (sem : semantics i) (e : i a) (f : a -> impure i b) : eval_impure sem (request_then e f) = eval_impure (exec_effect sem e) (f (eval_effect sem e)).
Proof. unfold eval_impure. now rewrite run_impure_request_then_assoc. Qed.
Lemma
eval_impure_request_then_assoc
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "eval_impure", "exec_effect", "impure", "run_impure_request_then_assoc", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_impure_request_then_assoc {i a b} (sem : semantics i) (e : i a) (f : a -> impure i b) : exec_impure sem (request_then e f) = exec_impure (exec_effect sem e) (f (eval_effect sem e)).
Proof. unfold exec_impure. now rewrite run_impure_request_then_assoc. Qed.
Lemma
exec_impure_request_then_assoc
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "exec_effect", "exec_impure", "impure", "run_impure_request_then_assoc", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_impure_bind_assoc {i a b} (sem : semantics i) (p : impure i a) (f : a -> impure i b) : run_impure sem (p >>= f) = run_impure (exec_impure sem p) (f (eval_impure sem p)).
Proof. revert sem f. induction p; intros sem g. + reflexivity. + rewrite bind_request_then_assoc. rewrite run_impure_request_then_assoc. rewrite H. rewrite exec_impure_request_then_assoc. rewrite eval_impure_request_then_assoc. reflexivity. Qed.
Lemma
run_impure_bind_assoc
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "bind_request_then_assoc", "eval_impure", "eval_impure_request_then_assoc", "exec_impure", "exec_impure_request_then_assoc", "impure", "run_impure", "run_impure_request_then_assoc", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_impure_bind_assoc {i a b} (sem : semantics i) (p : impure i a) (f : a -> impure i b) : eval_impure sem (p >>= f) = eval_impure (exec_impure sem p) (f (eval_impure sem p)).
Proof. unfold eval_impure. now rewrite run_impure_bind_assoc. Qed.
Lemma
eval_impure_bind_assoc
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_impure", "exec_impure", "impure", "run_impure_bind_assoc", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_impure_bind_assoc {i a b} (sem : semantics i) (p : impure i a) (f : a -> impure i b) : exec_impure sem (p >>= f) = exec_impure (exec_impure sem p) (f (eval_impure sem p)).
Proof. unfold exec_impure. now rewrite run_impure_bind_assoc. Qed.
Lemma
exec_impure_bind_assoc
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_impure", "exec_impure", "impure", "run_impure_bind_assoc", "semantics" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_impure_Proper_1 (i : interface) (a : Type) : Proper (semantics_eq ==> eq ==> run_effect_eq) (@run_impure i a).
Next Obligation. add_morphism_tactic. intros sem sem' equ p. revert sem sem' equ. induction p; intros sem sem' equ. + cbn. now rewrite equ. + repeat rewrite eval_impure_request_then_assoc. repeat rewrite run_impure_request_then_assoc. specialize H with (eval_effect sem e) (exec_effect sem ...
Instance
run_impure_Proper_1
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_effect", "eval_impure_request_then_assoc", "exec_effect", "interface", "repeat", "run_effect_eq", "run_impure", "run_impure_request_then_assoc", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
run_impure_Proper_2 (i : interface) (a : Type) : Proper (eq ==> impure_eq ==> run_effect_eq) (@run_impure i a).
Next Obligation. add_morphism_tactic. intros sem p q equ. revert sem. induction equ; intros sem. + reflexivity. + repeat rewrite run_impure_request_then_assoc. apply H. Qed.
Instance
run_impure_Proper_2
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "impure_eq", "interface", "repeat", "run_effect_eq", "run_impure", "run_impure_request_then_assoc" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval_impure_Proper (i : interface) (a : Type) : Proper (semantics_eq ==> impure_eq ==> eq) (@eval_impure i a).
Next Obligation. add_morphism_tactic. intros sem sem' equ1 p q equ2. unfold eval_impure. now rewrite equ1, equ2. Qed.
Instance
eval_impure_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "eval_impure", "impure_eq", "interface", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
exec_impure_Proper (i : interface) (a : Type) : Proper (semantics_eq ==> impure_eq ==> semantics_eq) (@exec_impure i a).
Next Obligation. add_morphism_tactic. intros sem sem' equ1 p q equ2. unfold exec_impure. now rewrite equ1, equ2. Qed.
Instance
exec_impure_Proper
Core
theories/Core/SemanticsFacts.v
[ "ExtLib", "StateMonad", "FreeSpec.Core", "ImpureFacts", "Contract", "Semantics" ]
[ "exec_impure", "impure_eq", "interface", "semantics_eq" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
destruct_if_when
:= let equ_cond := fresh "equ_cond" in match goal with | |- context[when (negb ?B) _] => case_eq B; intros equ_cond; cbn | |- context[when ?B _] => case_eq B; intros equ_cond; cbn | |- context[if (negb ?B) then _ else _] => case_eq B; intros equ_cond; cbn | |- context[if ?B then _ else _] => case_eq B; intr...
Ltac
destruct_if_when
Core
theories/Core/Tactics.v
[ "ExtLib", "Monad", "FreeSpec.Core", "Contract", "ImpureFacts", "HoareFacts" ]
[ "when" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
destruct_if_when_in hyp
:= let equ_cond := fresh "equ" in match type of hyp with | context[when (negb ?B) _] => case_eq B; intro equ_cond; rewrite equ_cond in hyp | context[when ?B _] => case_eq B; intro equ_cond; rewr...
Ltac
destruct_if_when_in
Core
theories/Core/Tactics.v
[ "ExtLib", "Monad", "FreeSpec.Core", "Contract", "ImpureFacts", "HoareFacts" ]
[ "when" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
simplify_gens
:= repeat match goal with | H : True |- _ => clear H | H: _ /\ _ |- _ => destruct H | |- context[@proj_p ?ix ?ix (refl_MayProvide ?ix) _ ?e] => change (@proj_p ix ix (refl_MayProvide ix) _ e) with (Some e); cbn match; cbn beta ...
Ltac
simplify_gens
Core
theories/Core/Tactics.v
[ "ExtLib", "Monad", "FreeSpec.Core", "Contract", "ImpureFacts", "HoareFacts" ]
[ "gen_callee_obligation", "gen_caller_obligation", "gen_witness_update", "refl_MayProvide", "repeat" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
prove_impure
:= repeat (cbn -[ to_hoare gen_caller_obligation gen_callee_obligation gen_witness_update ] in *; simplify_gens; destruct_if_when); lazymatch goal with | |- _ /\ _ => split; prove_impure | |- pre (to_hoare ?c (impure...
Ltac
prove_impure
Core
theories/Core/Tactics.v
[ "ExtLib", "Monad", "FreeSpec.Core", "Contract", "ImpureFacts", "HoareFacts" ]
[ "destruct_if_when", "eval", "gen_callee_obligation", "gen_caller_obligation", "gen_witness_update", "impure_apply", "impure_bind", "impure_bind_assoc", "impure_map", "repeat", "simplify_gens", "to_hoare", "to_hoare_pre_bind_assoc" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
unroll_post run
:= repeat (cbn -[ to_hoare gen_caller_obligation gen_callee_obligation gen_witness_update ] in *; simplify_gens; destruct_if_when_in run); lazymatch type of run with | post (to_hoare ?c ?p) ?ω ?x ?ω' => let p := (eval hnf i...
Ltac
unroll_post
Core
theories/Core/Tactics.v
[ "ExtLib", "Monad", "FreeSpec.Core", "Contract", "ImpureFacts", "HoareFacts" ]
[ "destruct_if_when_in", "eval", "gen_callee_obligation", "gen_caller_obligation", "gen_witness_update", "impure_bind", "interface_to_hoare", "repeat", "simplify_gens", "ssubst", "to_hoare", "to_hoare_post_bind_assoc" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
EVAL (a : Type) : Type
:= | Eval (x : a) : EVAL a.
Inductive
EVAL
Exec
theories/Exec/Eval.v
[ "FreeSpec", "Core" ]
[]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
eval `{Provide ix EVAL} {a} (x : a) : impure ix a
:= request (Eval x).
Definition
eval
Exec
theories/Exec/Eval.v
[ "FreeSpec", "Core" ]
[ "EVAL", "Provide", "impure", "request" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663
FreeSpec_Inject `(H : Provide ix i) : Inject i (impure ix)
:= { inject := @request ix i _ H }.
Instance
FreeSpec_Inject
FFI
theories/FFI/FFI.v
[ "FreeSpec", "Core", "Extraction", "CoqFFI", "Interface" ]
[ "Provide", "impure", "request" ]
https://github.com/lthms/FreeSpec
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663