Dataset Viewer
Auto-converted to Parquet Duplicate
fact
stringlengths
23
2.8k
type
stringclasses
15 values
library
stringclasses
3 values
imports
listlengths
1
5
filename
stringclasses
23 values
symbolic_name
stringlengths
1
55
docstring
stringclasses
1 value
door : Type := left | right.
Inductive
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
door
door_eq_dec (d d' : door) : { d = d' } + { ~ d = d' } := ltac:(decide equality).
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
door_eq_dec
DOORS : interface := | IsOpen : door -> DOORS bool | Toggle : door -> DOORS unit. Generalizable All Variables.
Inductive
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
DOORS
is_open `{Provide ix DOORS} (d : door) : impure ix bool := request (IsOpen d).
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
is_open
toggle `{Provide ix DOORS} (d : door) : impure ix unit := request (Toggle d).
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
toggle
open_door `{Provide ix DOORS} (d : door) : impure ix unit := let* open := is_open d in when (negb open) (toggle d).
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
open_door
close_door `{Provide ix DOORS} (d : door) : impure ix unit := let* open := is_open d in when open (toggle d). (** ** Controller *)
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
close_door
CONTROLLER : interface := | Tick : CONTROLLER unit | RequestOpen (d : door) : CONTROLLER unit.
Inductive
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
CONTROLLER
tick `{Provide ix CONTROLLER} : impure ix unit := request Tick.
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
tick
request_open `{Provide ix CONTROLLER} (d : door) : impure ix unit := request (RequestOpen d).
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
request_open
co (d : door) : door := match d with | left => right | right => left end.
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
co
controller `{Provide ix DOORS, Provide ix (STORE nat)} : component CONTROLLER ix := fun _ op => match op with | Tick => let* cpt := get in when (15 <? cpt) begin close_door left;; close_door right;; put 0 end | RequestOpen d => close_door (co d);; open_door d;; put 0 end. (** * Verifying the Airlock Controller *) (** *...
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
controller
Ω : Type := bool * bool.
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
Ω
sel (d : door) : Ω -> bool := match d with | left => fst | right => snd end.
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
sel
tog (d : door) (ω : Ω) : Ω := match d with | left => (negb (fst ω), snd ω) | right => (fst ω, negb (snd ω)) end.
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
tog
tog_equ_1 (d : door) (ω : Ω) : sel d (tog d ω) = negb (sel d ω). Proof. destruct d; reflexivity. Qed.
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
tog_equ_1
tog_equ_2 (d : door) (ω : Ω) : sel (co d) (tog d ω) = sel (co d) ω. Proof. destruct d; reflexivity. Qed. (** From now on, we will reason about [tog] using [tog_equ_1] and [tog_equ_2]. FreeSpec tactics rely heavily on [cbn] to simplify certain terms, so we use the <<simpl never>> options of the [Arguments] vernacular co...
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
tog_equ_2
step (ω : Ω) (a : Type) (e : DOORS a) (x : a) := match e with | Toggle d => tog d ω | _ => ω end. (** *** Requirements *)
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
step
doors_o_caller : Ω -> forall (a : Type), DOORS a -> Prop := (** - Given the door [d] of o system [ω], it is always possible to ask for the state of [d]. *) | req_is_open (d : door) (ω : Ω) : doors_o_caller ω bool (IsOpen d) (** - Given the door [d] of o system [ω], if [d] is closed, then the second door [co d] has to b...
Inductive
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
doors_o_caller
doors_o_callee : Ω -> forall (a : Type), DOORS a -> a -> Prop := (** - When a system in a state [ω] reports the state of the door [d], it shall reflect the true state of [d]. *) | doors_o_callee_is_open (d : door) (ω : Ω) (x : bool) (equ : sel d ω = x) : doors_o_callee ω bool (IsOpen d) x (** - There is no particular d...
Inductive
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
doors_o_callee
doors_contract : contract DOORS Ω := make_contract step doors_o_caller doors_o_callee. (** ** Intermediary Lemmas *) (** Closing a door [d] in any system [ω] is always a respectful operation. *)
Definition
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
doors_contract
close_door_respectful `{Provide ix DOORS} (ω : Ω) (d : door) : pre (to_hoare doors_contract (close_door d)) ω. Proof. (* We use the [prove_program] tactics to erase the program monad *) prove impure with airlock; subst; constructor. (* This leaves us with one goal to prove: [sel d ω = false -> sel (co d) ω = false] Yet...
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
close_door_respectful
open_door_respectful `{Provide ix DOORS} (ω : Ω) (d : door) (safe : sel (co d) ω = false) : pre (to_hoare doors_contract (open_door (ix := ix) d)) ω. Proof. prove impure; repeat constructor; subst. inversion o_caller0; ssubst. now rewrite safe. Qed. #[global] Hint Resolve open_door_respectful : airlock.
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
open_door_respectful
close_door_run `{Provide ix DOORS} (ω : Ω) (d : door) (ω' : Ω) (x : unit) (run : post (to_hoare doors_contract (close_door d)) ω x ω') : sel d ω' = false. Proof. unroll_post run. + rewrite tog_equ_1. inversion H1; ssubst. now rewrite H5. + now inversion H1; ssubst. Qed. #[global] Hint Resolve close_door_run : airlock. ...
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
close_door_run
one_door_safe_all_doors_safe (ω : Ω) (d : door) (safe : sel d ω = false \/ sel (co d) ω = false) : forall (d' : door), sel d' ω = false \/ sel (co d') ω = false. Proof. intros d'. destruct d; destruct d'; auto. + cbn -[sel]. now rewrite or_comm. + cbn -[sel]. fold (co right). now rewrite or_comm. Qed. (** The objective...
Remark
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
one_door_safe_all_doors_safe
respectful_run_inv `{Provide ix DOORS} {a} (p : impure ix a) (ω : Ω) (safe : sel left ω = false \/ sel right ω = false) (x : a) (ω' : Ω) (hpre : pre (to_hoare doors_contract p) ω) (hpost : post (to_hoare doors_contract p) ω x ω') : sel left ω' = false \/ sel right ω' = false. (** We reason by induction on the impure co...
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
respectful_run_inv
controller_correct `{StrictProvide2 ix DOORS (STORE nat)} : correct_component controller (no_contract CONTROLLER) doors_contract (fun _ ω => sel left ω = false \/ sel right ω = false). Proof. intros ωc ωd pred a e req. assert (hpre : pre (to_hoare doors_contract (controller a e)) ωd) by (destruct e; prove impure with a...
Lemma
examples
[ "From Coq Require Import Arith.", "From FreeSpec.Core Require Import Core CoreFacts." ]
examples/airlock.v
controller_correct
with_heap `{Monad m, MonadRefs m} : m string := let* ptr := make_ref 2 in assign ptr 3;; let* x := deref ptr in if Nat.eqb x 2 then pure "yes!" else pure "no!". (* Coq projects the [with_heap] polymorphic definition directly into [impure], thanks to its typeclass inference algorithm. *)
Definition
examples
[ "From FreeSpec.Core Require Import Core Extraction.", "From FreeSpec.FFI Require Import FFI Refs.", "From FreeSpec.Exec Require Import Exec.", "From Coq Require Import String." ]
examples/heap.v
with_heap
with_heap_impure `{Provide ix REFS} : impure ix string := with_heap. Exec with_heap_impure.
Definition
examples
[ "From FreeSpec.Core Require Import Core Extraction.", "From FreeSpec.FFI Require Import FFI Refs.", "From FreeSpec.Exec Require Import Exec.", "From Coq Require Import String." ]
examples/heap.v
with_heap_impure
MEMORY : interface := | ReadFrom (addr : address) : MEMORY cell | WriteTo (addr : address) (value : cell) : MEMORY unit.
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
MEMORY
DRAM : interface := | MakeDRAM {a : Type} (e : MEMORY a) : DRAM a.
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
DRAM
dram_read_from `{Provide ix DRAM} (addr : address) : impure ix cell := request (MakeDRAM (ReadFrom addr)).
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
dram_read_from
dram_write_to `{Provide ix DRAM} (addr : address) (val : cell) : impure ix unit := request (MakeDRAM (WriteTo addr val)).
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
dram_write_to
VGA : interface := | MakeVGA {a : Type} (e : MEMORY a) : VGA a.
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
VGA
vga_read_from `{Provide ix VGA} (addr : address) : impure ix cell := request (MakeVGA (ReadFrom addr)).
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
vga_read_from
vga_write_to `{Provide ix VGA} (addr : address) (val : cell) : impure ix unit := request (MakeVGA (WriteTo addr val)). (** ** Memory Controller *)
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
vga_write_to
smiact := smiact_set | smiact_unset.
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
smiact
MEMORY_CONTROLLER : interface := | Read (pin : smiact) (addr : address) : MEMORY_CONTROLLER cell | Write (pin : smiact) (addr : address) (value : cell) : MEMORY_CONTROLLER unit.
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
MEMORY_CONTROLLER
unwrap_sumbool {A B} (x : { A } + { B }) : bool := if x then true else false.
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
unwrap_sumbool
unwrap_sumbool : sumbool >-> bool.
Coercion
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
unwrap_sumbool
dispatch {a} `{Provide3 ix (STORE bool) DRAM VGA} (addr : address) (unpriv : address -> impure ix a) (priv : address -> impure ix a) : impure ix a := let* reg := get in if (andb reg (in_smram addr)) then unpriv addr else priv addr.
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
dispatch
memory_controller `{Provide3 ix (STORE bool) DRAM VGA} : component MEMORY_CONTROLLER ix := fun _ op => match op with (** When SMIACT is set, the CPU is in SMM. According to its specification, the Memory Controller can simply forward the memory access to the DRAM. *) | Read smiact_set addr => dram_read_from addr | Write...
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
memory_controller
memory_view : Type := address -> cell.
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
memory_view
update_memory_view_address (ω : memory_view) (addr : address) (content : cell) : memory_view := fun (addr' : address) => if address_eq_dec addr addr' then content else ω addr'. (** ** Specification *) (** *** DRAM Controller Specification *)
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
update_memory_view_address
update_dram_view (ω : memory_view) (a : Type) (p : DRAM a) (_ : a) : memory_view := match p with | MakeDRAM (WriteTo a v) => update_memory_view_address ω a v | _ => ω end.
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
update_dram_view
dram_o_callee (ω : memory_view) : forall (a : Type), DRAM a -> a -> Prop := | read_in_smram (a : address) (v : cell) (prom : in_smram a = true -> v = ω a) : dram_o_callee ω cell (MakeDRAM (ReadFrom a)) (ω a) | write (a : address) (v : cell) (r : unit) : dram_o_callee ω unit (MakeDRAM (WriteTo a v)) r.
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
dram_o_callee
dram_specs : contract DRAM memory_view := {| witness_update := update_dram_view ; caller_obligation := no_caller_obligation ; callee_obligation := dram_o_callee |}. (** *** Memory Controller Specification *)
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
dram_specs
update_memory_controller_view (ω : memory_view) (a : Type) (p : MEMORY_CONTROLLER a) (_ : a) : memory_view := match p with | Write smiact_set a v => update_memory_view_address ω a v | _ => ω end.
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
update_memory_controller_view
memory_controller_o_callee (ω : memory_view) : forall (a : Type) (p : MEMORY_CONTROLLER a) (x : a), Prop := | memory_controller_read_o_callee (pin : smiact) (addr : address) (content : cell) (prom : pin = smiact_set -> in_smram addr = true -> ω addr = content) : memory_controller_o_callee ω cell (Read pin addr) content...
Inductive
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
memory_controller_o_callee
mc_specs : contract MEMORY_CONTROLLER memory_view := {| witness_update := update_memory_controller_view ; caller_obligation := no_caller_obligation ; callee_obligation := memory_controller_o_callee |}. (** ** Main Theorem *)
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
mc_specs
smram_pred (ωmc : memory_view) (ωmem : memory_view * bool) : Prop := snd ωmem = true /\ forall (a : address), in_smram a = true -> ωmc a = (fst ωmem) a.
Definition
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
smram_pred
memory_controller_respectful `{StrictProvide3 ix (STORE bool) VGA DRAM} (a : Type) (op : MEMORY_CONTROLLER a) (ω : memory_view) : pre (to_hoare (dram_specs * store_specs bool) (memory_controller a op)) (ω, true). Proof. destruct op; destruct pin; prove impure. Qed. #[local] Open Scope semantics_scope. #[local] Open Sco...
Lemma
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
memory_controller_respectful
simpl_tuple := match goal with | H: (_, _) = (_, _) |- _ => inversion H; subst; clear H end.
Ltac
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
simpl_tuple
memory_controller_correct `{StrictProvide3 ix VGA (STORE bool) DRAM} (ω : memory_view) (sem : semantics ix) (comp : compliant_semantics (dram_specs * store_specs bool) (ω, true) sem) : compliant_semantics mc_specs ω (derive_semantics memory_controller sem). Proof. apply correct_component_derives_compliant_semantics wit...
Theorem
examples
[ "From Coq Require Import ZArith.", "From FreeSpec Require Import Core CoreFacts." ]
examples/smram.v
memory_controller_correct
COUNTER : interface := | Get : COUNTER nat | Inc : COUNTER unit | Dec : COUNTER unit.
Inductive
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
COUNTER
counter_get `{Provide ix COUNTER} : impure ix nat := request Get.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
counter_get
counter_inc `{Provide ix COUNTER} : impure ix unit := request Inc.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
counter_inc
counter_dec `{Provide ix COUNTER} : impure ix unit := request Dec.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
counter_dec
repeat {m : Type -> Type} `{Monad m} {a} (n : nat) (c : m a) : m unit := match n with | O => pure tt | S n => (c >>= fun _ => repeat n c) end.
Fixpoint
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
repeat
update_counter (x : nat) : forall (a : Type), COUNTER a -> a -> nat := fun (a : Type) (p : COUNTER a) (_ : a) => match p with | Inc => S x | Dec => Nat.pred x | _ => x end.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
update_counter
counter_o_caller (x : nat) : forall (a : Type), COUNTER a -> Prop := fun (a : Type) (p : COUNTER a) => match p with | Dec => 0 < x | _ => True end.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
counter_o_caller
counter_o_callee (x : nat) : forall (a : Type), COUNTER a -> a -> Prop := fun (a : Type) (p : COUNTER a) (r : a) => match p, r with | Get, r => r = x | _, _ => True end.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
counter_o_callee
counter_specs : contract COUNTER nat := {| witness_update := update_counter ; caller_obligation := counter_o_caller ; callee_obligation := counter_o_callee |}.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
counter_specs
dec_then_inc `{Provide ix COUNTER} (x y : nat) : impure ix nat := repeat x counter_dec;; repeat y counter_inc;; counter_get.
Definition
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
dec_then_inc
dec_then_inc_respectful `{Provide ix COUNTER} (cpt x y : nat) (init_cpt : x < cpt) : pre (to_hoare counter_specs $ dec_then_inc x y) cpt. Proof. prove impure. + revert x cpt init_cpt. induction x; intros cpt init_cpt; prove impure. ++ cbn. transitivity (S x); auto. apply PeanoNat.Nat.lt_0_succ. ++ apply IHx. now apply ...
Theorem
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
dec_then_inc_respectful
repeat_dec_cpt_output `(run : post (to_hoare counter_specs $ repeat x counter_dec) cpt r cpt') (init_cpt : x < cpt) : cpt' = cpt - x. Proof. revert init_cpt run; revert cpt; induction x; intros cpt init_cpt run. + unroll_post run. now rewrite PeanoNat.Nat.sub_0_r. + unroll_post run. apply IHx in run; [| lia]. subst. li...
Lemma
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
repeat_dec_cpt_output
repeat_inc_cpt_output `(run : post (to_hoare counter_specs $ repeat x counter_inc) cpt r cpt') : cpt' = cpt + x. Proof. revert run; revert cpt; induction x; intros cpt run. + unroll_post run. now rewrite PeanoNat.Nat.add_0_r. + unroll_post run. apply IHx in run. lia. Qed. #[local] Hint Resolve repeat_inc_cpt_output : c...
Lemma
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
repeat_inc_cpt_output
get_cpt_output (cpt x cpt' : nat) (run : post (to_hoare counter_specs $ counter_get) cpt x cpt') : cpt' = cpt. Proof. now unroll_post run. Qed. #[local] Hint Resolve get_cpt_output : counter. #[local] Opaque counter_get.
Lemma
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
get_cpt_output
dec_then_inc_cpt_output (cpt x y cpt' r : nat) (init_cpt : x < cpt) (run : post (to_hoare counter_specs $ dec_then_inc x y) cpt r cpt') : cpt' = cpt - x + y. Proof. unroll_post run. apply repeat_dec_cpt_output in run0; [| exact init_cpt ]. apply repeat_inc_cpt_output in run. apply get_cpt_output in run2. lia. Qed. #[lo...
Theorem
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
dec_then_inc_cpt_output
dec_then_inc_output (cpt x y cpt' r : nat) (init_cpt : x < cpt) (run : post (to_hoare counter_specs $ dec_then_inc x y) cpt r cpt') : cpt' = r. Proof. now unroll_post run. Qed.
Theorem
tests
[ "From FreeSpec.Core Require Import CoreFacts.", "From Coq Require Import Lia." ]
tests/core_tactics.v
dec_then_inc_output
enum {a b ix} (p : a -> impure ix b) (l : list a) {measure (length l)} : impure ix unit := match l with | nil => pure tt | cons x rst => p x;; enum p rst end. Fail Timeout 1 Exec (enum eval [true; true; false]). (** We have provided an attribute for [Exec] which slightly changes the behavior of the command (see the doc...
Fixpoint
tests
[ "From FreeSpec.Exec Require Import Exec Eval.", "From Coq.Program Require Import Wf.", "From Coq Require Import List." ]
tests/program_fixpoint.v
enum
p1 : forall `{Provide ix}, impure ix nat.
Axiom
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
p1
p2 : forall `{Provide2 ix i3 i1}, impure ix nat.
Axiom
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
p2
p `{Provide4 ix i1 i4 i3 i2} : impure ix nat := p1;; p2.
Definition
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
p
provide_notation_test_1 {a} `{StrictProvide3 ix i1 i2 i3} (p : i2 a) : ix a := inj_p p.
Definition
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
provide_notation_test_1
provide_notation_test_2 `{StrictProvide3 ix i1 i2 i3} : StrictProvide2 ix i2 i3. Proof. typeclasses eauto. Qed.
Lemma
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
provide_notation_test_2
provide_notation_test_3 {a} (i1 i2 i3 : interface) (p : i2 a) : (iplus (iplus i1 i2) i3) a := inj_p p.
Definition
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
provide_notation_test_3
provide_notation_test_4 (i1 i2 i3 : interface) : Provide (i1 + (i2 + i3)) i2. Proof. typeclasses eauto. Qed.
Lemma
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
provide_notation_test_4
provide_notation_test_5 (i1 i2 i3 : interface) : StrictProvide2 (i1 + i2 + i3) i2 i1. Proof. typeclasses eauto. Qed.
Lemma
tests
[ "From FreeSpec.Core Require Import Core." ]
tests/provide_notation.v
provide_notation_test_5
component (i j : interface) : Type := forall (α : Type), i α -> impure j α. (** The similarity between FreeSpec components and operational semantics may be confusing at first. The main difference between the two concepts is simple: operational semantics are self-contained terms which can, alone, be used to interpret im...
Definition
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Export Interface Semantics Impure." ]
theories/Core/Component.v
component
bootstrap {i} (c : component i iempty) : semantics i := derive_semantics c iempty_semantics. (** * In-place Primitives Handling *) (** The function [with_component] allows for locally providing an additional interface [j] within an impure computation of type [impure ix a]. The primitives of [j] will be handled by impur...
Definition
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Export Interface Semantics Impure." ]
theories/Core/Component.v
bootstrap
with_component_aux {ix j α} (c : component j ix) (p : impure (ix + j) α) : impure ix α := match p with | local x => local x | request_then (in_right e) f => c _ e >>= fun res => with_component_aux c (f res) | request_then (in_left e) f => request_then e (fun x => with_component_aux c (f x)) end.
Fixpoint
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Export Interface Semantics Impure." ]
theories/Core/Component.v
with_component_aux
with_component {ix j α} (initializer : impure ix unit) (c : component j ix) (finalizer : impure ix unit) (p : impure (ix + j) α) : impure ix α := initializer;; let* res := with_component_aux c p in finalizer;; pure res.
Definition
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Export Interface Semantics Impure." ]
theories/Core/Component.v
with_component
derive_semantics_equ `(c : component i j) (sem : semantics j) : (derive_semantics c sem === derive_semantics' c sem)%semantics. Proof. revert sem. cofix aux; intros sem. constructor; intros a e; cbn; unfold derive_semantics; unfold eval_effect; unfold exec_effect; unfold run_effect; unfold evalState; unfold execState; ...
Remark
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Import Contract HoareFacts SemanticsFacts InstrumentFacts.", "From FreeSpec Require Export Component." ]
theories/Core/ComponentFacts.v
derive_semantics_equ
correct_component `{MayProvide jx j} `(c : component i jx) `(ci : contract i Ωi) `(cj : contract j Ωj) (pred : Ωi -> Ωj -> Prop) : Prop := forall (ωi : Ωi) (ωj : Ωj) (init : pred ωi ωj) `(e : i α) (o_caller : caller_obligation ci ωi e), pre (to_hoare cj $ c α e) ωj /\ forall (x : α) (ωj' : Ωj) (run : post (to_hoare cj ...
Definition
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Import Contract HoareFacts SemanticsFacts InstrumentFacts.", "From FreeSpec Require Export Component." ]
theories/Core/ComponentFacts.v
correct_component
correct_component_derives_compliant_semantics `{MayProvide jx j} `(c : component i jx) `(ci : contract i Ωi) `(cj : contract j Ωj) (pred : Ωi -> Ωj -> Prop) (correct : correct_component c ci cj pred) (ωi : Ωi) (ωj : Ωj) (inv : pred ωi ωj) (sem : semantics jx) (comp : compliant_semantics cj ωj sem) : compliant_semantics...
Lemma
theories
[ "From ExtLib Require Import StateMonad.", "From FreeSpec.Core Require Import Contract HoareFacts SemanticsFacts InstrumentFacts.", "From FreeSpec Require Export Component." ]
theories/Core/ComponentFacts.v
correct_component_derives_compliant_semantics
contract (i : interface) (Ω : Type) : Type := make_contract { witness_update (ω : Ω) : forall (α : Type), i α -> α -> Ω ; caller_obligation (ω : Ω) : forall (α : Type), i α -> Prop ; callee_obligation (ω : Ω) : forall (α : Type), i α -> α -> Prop }. Declare Scope contract_scope. Bind Scope contract_scope with contract....
Record
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract
const_witness {i} := fun (u : unit) (α : Type) (e : i α) (x : α) => u.
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
const_witness
no_caller_obligation {i Ω} (ω : Ω) (α : Type) (e : i α) : Prop := | mk_no_caller_obligation : no_caller_obligation ω α e. #[global] Hint Constructors no_caller_obligation : freespec.
Inductive
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
no_caller_obligation
no_callee_obligation {i Ω} (ω : Ω) (α : Type) (e : i α) (x : α) : Prop := | mk_no_callee_obligation : no_callee_obligation ω α e x. #[global] Hint Constructors no_callee_obligation : freespec.
Inductive
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
no_callee_obligation
no_contract (i : interface) : contract i unit := {| witness_update := const_witness ; caller_obligation := no_caller_obligation ; callee_obligation := no_callee_obligation |}. (** A similar —and as simple— contract is the one that forbids the use of a given interface. *)
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
no_contract
do_no_use {i Ω} (ω : Ω) (α : Type) (e : i α) : Prop := False.
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
do_no_use
forbid_specs (i : interface) : contract i unit := {| witness_update := const_witness ; caller_obligation := do_no_use ; callee_obligation := no_callee_obligation |}. (** * Contract Equivalence *)
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
forbid_specs
contract_caller_equ `(c1 : contract i Ω1) `(c2 : contract i Ω2) (f : Ω1 -> Ω2) : Prop := forall ω1 a (p : i a), caller_obligation c1 ω1 p <-> caller_obligation c2 (f ω1) p.
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_caller_equ
contract_callee_equ `(c1 : contract i Ω1) `(c2 : contract i Ω2) (f : Ω1 -> Ω2) : Prop := forall ω1 a (p : i a) x, callee_obligation c1 ω1 p x <-> callee_obligation c2 (f ω1) p x.
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_callee_equ
contract_witness_equ `(c1 : contract i Ω1) `(c2 : contract i Ω2) (f : Ω1 -> Ω2) : Prop := forall ω1 a (p : i a) x, f (witness_update c1 ω1 p x) = witness_update c2 (f ω1) p x.
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_witness_equ
contract_equ `(c1 : contract i Ω1) `(c2 : contract i Ω2) : Type := | mk_contract_equ (f : Ω1 -> Ω2) (g : Ω2 -> Ω1) (iso1 : forall x, f (g x) = x) (iso2 : forall x, g (f x) = x) (caller_equ : contract_caller_equ c1 c2 f) (callee_equ : contract_callee_equ c1 c2 f) (witness_equ : contract_witness_equ c1 c2 f) : contract_e...
Inductive
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_equ
contract_iso_lr `(c1 : contract i Ω1) `(c2 : contract i Ω2) (equ : contract_equ c1 c2) (ω1 : Ω1) : Ω2 := match equ with | @mk_contract_equ _ _ _ _ _ f _ _ _ _ _ _ => f ω1 end.
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_iso_lr
contract_iso_rl `(c1 : contract i Ω1) `(c2 : contract i Ω2) (equ : contract_equ c1 c2) (ω2 : Ω2) : Ω1 := match equ with | @mk_contract_equ _ _ _ _ _ _ g _ _ _ _ _ => g ω2 end. Arguments contract_iso_lr {i Ω1 c1 Ω2 c2} (equ ω1). Arguments contract_iso_rl {i Ω1 c1 Ω2 c2} (equ ω2).
Definition
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_iso_rl
contract_equ_refl `(c : contract i Ω) : contract_equ c c. Proof. apply mk_contract_equ with (f:=fun x => x) (g:=fun x => x); auto. + now intros ω α p. + now intros ω α p x. + now intros ω α p x. Defined.
Lemma
theories
[ "From Coq Require Import Setoid Morphisms.", "From ExtLib Require Import StateMonad MonadState MonadTrans.", "From FreeSpec.Core Require Import Interface Impure Semantics Component." ]
theories/Core/Contract.v
contract_equ_refl
End of preview. Expand in Data Studio

Coq-FreeSpec

Structured dataset from FreeSpec — Modular verification of effectful programs.

279 declarations extracted from Coq source files.

Applications

  • Training language models on formal proofs
  • Fine-tuning theorem provers
  • Retrieval-augmented generation for proof assistants
  • Learning proof embeddings and representations

Source

Schema

Column Type Description
fact string Declaration body
type string Lemma, Definition, Theorem, etc.
library string Source module
imports list Required imports
filename string Source file path
symbolic_name string Identifier
Downloads last month
4

Collection including phanerozoic/Coq-FreeSpec