Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion. • 103 items • Updated • 3
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 |
|---|---|---|---|---|---|---|---|---|---|---|
door : Type | := left | right. | Inductive | door | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [] | ** Doors | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
door_eq_dec (d d' : door) : { d = d' } + { ~ d = d' } | :=
ltac:(decide equality). | Definition | door_eq_dec | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
DOORS : interface | :=
| IsOpen : door -> DOORS bool
| Toggle : door -> DOORS unit. | Inductive | DOORS | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door",
"interface"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
is_open `{Provide ix DOORS} (d : door) : impure ix bool | :=
request (IsOpen d). | Definition | is_open | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"door",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
toggle `{Provide ix DOORS} (d : door) : impure ix unit | :=
request (Toggle d). | Definition | toggle | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"door",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
open_door `{Provide ix DOORS} (d : door) : impure ix unit | :=
let* open := is_open d in
when (negb open) (toggle d). | Definition | open_door | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"door",
"impure",
"is_open",
"toggle",
"when"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
close_door `{Provide ix DOORS} (d : door) : impure ix unit | :=
let* open := is_open d in
when open (toggle d). | Definition | close_door | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"door",
"impure",
"is_open",
"toggle",
"when"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
CONTROLLER : interface | :=
| Tick : CONTROLLER unit
| RequestOpen (d : door) : CONTROLLER unit. | Inductive | CONTROLLER | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door",
"interface"
] | ** Controller | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
tick `{Provide ix CONTROLLER} : impure ix unit | :=
request Tick. | Definition | tick | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"CONTROLLER",
"Provide",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
request_open `{Provide ix CONTROLLER} (d : door) : impure ix unit | :=
request (RequestOpen d). | Definition | request_open | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"CONTROLLER",
"Provide",
"door",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
co (d : door) : door | :=
match d with
| left => right
| right => left
end. | Definition | co | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Definition | controller | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"CONTROLLER",
"DOORS",
"Provide",
"STORE",
"close_door",
"co",
"component",
"open_door",
"when"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
Ω : Type | := bool * bool. | Definition | Ω | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [] | *** Witness States | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
sel (d : door) : Ω -> bool | :=
match d with
| left => fst
| right => snd
end. | Definition | sel | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
tog (d : door) (ω : Ω) : Ω | :=
match d with
| left => (negb (fst ω), snd ω)
| right => (fst ω, negb (snd ω))
end. | Definition | tog | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
tog_equ_1 (d : door) (ω : Ω)
: sel d (tog d ω) = negb (sel d ω). | Proof.
destruct d; reflexivity.
Qed. | Lemma | tog_equ_1 | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"door",
"sel",
"tog"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
tog_equ_2 (d : door) (ω : Ω)
: sel (co d) (tog d ω) = sel (co d) ω. | Proof.
destruct d; reflexivity.
Qed. | Lemma | tog_equ_2 | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"co",
"door",
"sel",
"tog"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
step (ω : Ω) (a : Type) (e : DOORS a) (x : a) | :=
match e with
| Toggle d => tog d ω
| _ => ω
end. | Definition | step | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"tog"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 be closed too for a request to toggle [d]... | Inductive | doors_o_caller | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"co",
"door",
"sel"
] | *** Requirements | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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 doors_o_calleeises on the result [x] of a request fo... | Inductive | doors_o_callee | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"door",
"sel"
] | *** Promises | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
doors_contract : contract DOORS Ω | :=
make_contract step doors_o_caller doors_o_callee. | Definition | doors_contract | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"contract",
"doors_o_callee",
"doors_o_caller",
"step"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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, thanks to our call to [IsOpen d], we can predict that
[sel d ω = true] *)
in... | Lemma | close_door_respectful | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"close_door",
"door",
"doors_contract",
"impure",
"ssubst",
"to_hoare"
] | Closing a door [d] in any system [ω] is always a respectful operation. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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. | Lemma | open_door_respectful | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"co",
"door",
"doors_contract",
"impure",
"open_door",
"repeat",
"sel",
"ssubst",
"to_hoare"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Lemma | close_door_run | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"close_door",
"door",
"doors_contract",
"sel",
"ssubst",
"to_hoare",
"tog_equ_1",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Remark | one_door_safe_all_doors_safe | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"co",
"door",
"sel"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 computation [p]:
- Either [p] is a local, pure computation; in such a case, the doors state
does not change, hence the proof is trivial.
- Or [p] consists in a request to the doors interface, and a continuation
whose domain satisfies the theorem, i.e. it pr... | Lemma | respectful_run_inv | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"DOORS",
"Provide",
"co",
"doors_contract",
"gen_callee_obligation",
"gen_caller_obligation",
"gen_witness_update",
"impure",
"interface_to_hoare",
"one_door_safe_all_doors_safe",
"sel",
"ssubst",
"to_hoare",
"tog_equ_2",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 airlock).
split; auto.
intros x ωj' run.
cbn.
split.
+ auto with freespec.
+ apply respectful_run_inv in run; auto.
Qed. | Lemma | controller_correct | examples | examples/airlock.v | [
"Coq",
"Arith",
"FreeSpec.Core",
"Core",
"CoreFacts"
] | [
"CONTROLLER",
"DOORS",
"STORE",
"controller",
"correct_component",
"doors_contract",
"impure",
"no_contract",
"respectful_run_inv",
"sel",
"to_hoare"
] | ** Main Theorem | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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!". | Definition | with_heap | examples | examples/heap.v | [
"FreeSpec.Core",
"Core",
"Extraction",
"FreeSpec.FFI",
"FFI",
"Refs",
"FreeSpec.Exec",
"Exec",
"Coq",
"String"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
with_heap_impure `{Provide ix REFS} : impure ix string | :=
with_heap. | Definition | with_heap_impure | examples | examples/heap.v | [
"FreeSpec.Core",
"Core",
"Extraction",
"FreeSpec.FFI",
"FFI",
"Refs",
"FreeSpec.Exec",
"Exec",
"Coq",
"String"
] | [
"Provide",
"impure",
"with_heap"
] | Coq projects the [with_heap] polymorphic definition directly into [impure],
thanks to its typeclass inference algorithm. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
(address cell : Type)
(address_eq : address -> address -> Prop)
(address_eq_refl : forall (addr addr' : address),
address_eq addr addr' -> address_eq addr' addr)
(address_eq_dec : forall (addr addr' : address),
{ address_eq addr addr' } + { ~ address_eq add... | Parameters | address | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [] | We leave how the memory is actually addressed (in terms of memory cell
addresses and contents) as a parameter of the model. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
MEMORY : interface | :=
| ReadFrom (addr : address) : MEMORY cell
| WriteTo (addr : address) (value : cell) : MEMORY unit. | Inductive | MEMORY | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"address",
"interface"
] | We consider that the DRAM and VGA controllers expose the same interface
which allows for reading from and writing to memory cells. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
DRAM : interface | :=
| MakeDRAM {a : Type} (e : MEMORY a) : DRAM a. | Inductive | DRAM | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"MEMORY",
"interface"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
dram_read_from `{Provide ix DRAM} (addr : address)
: impure ix cell | :=
request (MakeDRAM (ReadFrom addr)). | Definition | dram_read_from | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"Provide",
"address",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
dram_write_to `{Provide ix DRAM} (addr : address) (val : cell)
: impure ix unit | :=
request (MakeDRAM (WriteTo addr val)). | Definition | dram_write_to | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"Provide",
"address",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
VGA : interface | :=
| MakeVGA {a : Type} (e : MEMORY a) : VGA a. | Inductive | VGA | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"MEMORY",
"interface"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
vga_read_from `{Provide ix VGA} (addr : address) : impure ix cell | :=
request (MakeVGA (ReadFrom addr)). | Definition | vga_read_from | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"Provide",
"VGA",
"address",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
vga_write_to `{Provide ix VGA} (addr : address) (val : cell)
: impure ix unit | :=
request (MakeVGA (WriteTo addr val)). | Definition | vga_write_to | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"Provide",
"VGA",
"address",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
smiact | := smiact_set | smiact_unset. | Inductive | smiact | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [] | ** Memory Controller | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
MEMORY_CONTROLLER : interface | :=
| Read (pin : smiact) (addr : address) : MEMORY_CONTROLLER cell
| Write (pin : smiact) (addr : address) (value : cell) : MEMORY_CONTROLLER unit. | Inductive | MEMORY_CONTROLLER | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"address",
"interface",
"smiact"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
unwrap_sumbool {A B} (x : { A } + { B }) : bool | :=
if x then true else false. | Definition | unwrap_sumbool | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
unwrap_sumbool : sumbool >-> bool. | Coercion | unwrap_sumbool | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | ||
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 | dispatch | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"STORE",
"VGA",
"address",
"impure"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 smiact_set addr val => dram_write_to addr val
(** On the contrary... | Definition | memory_controller | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"MEMORY_CONTROLLER",
"STORE",
"VGA",
"component",
"dispatch",
"dram_read_from",
"dram_write_to",
"vga_read_from",
"vga_write_to"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
memory_view : Type | := address -> cell. | Definition | memory_view | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"address"
] | ** Memory View | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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'. | Definition | update_memory_view_address | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"address",
"memory_view"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | update_dram_view | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"memory_view",
"update_memory_view_address"
] | *** DRAM Controller Specification | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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 | dram_o_callee | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"address",
"memory_view"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
dram_specs : contract DRAM memory_view | :=
{| witness_update := update_dram_view
; caller_obligation := no_caller_obligation
; callee_obligation := dram_o_callee
|}. | Definition | dram_specs | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"contract",
"dram_o_callee",
"memory_view",
"no_caller_obligation",
"update_dram_view"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | update_memory_controller_view | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"MEMORY_CONTROLLER",
"memory_view",
"update_memory_view_address"
] | *** Memory Controller Specification | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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
| memory_controller_write_o_callee (pin : smiact) (addr : address) (content : cell) (b : unit)
... | Inductive | memory_controller_o_callee | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"MEMORY_CONTROLLER",
"address",
"memory_view",
"smiact"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
mc_specs : contract MEMORY_CONTROLLER memory_view | :=
{| witness_update := update_memory_controller_view
; caller_obligation := no_caller_obligation
; callee_obligation := memory_controller_o_callee
|}. | Definition | mc_specs | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"MEMORY_CONTROLLER",
"contract",
"memory_controller_o_callee",
"memory_view",
"no_caller_obligation",
"update_memory_controller_view"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | smram_pred | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"address",
"memory_view"
] | ** Main Theorem | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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. | Lemma | memory_controller_respectful | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"MEMORY_CONTROLLER",
"STORE",
"VGA",
"dram_specs",
"impure",
"memory_controller",
"memory_view",
"store_specs",
"to_hoare"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
simpl_tuple | :=
match goal with
| H: (_, _) = (_, _) |- _ => inversion H; subst; clear H
end. | Ltac | simpl_tuple | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 with (pred := smram_pred)
(cj := dram_specs * store_specs bool)
(ωj := (ω, true)).
+ intros ωmc [ωdram b] [b_true pred] a e _.
cbn in b... | Theorem | memory_controller_correct | examples | examples/smram.v | [
"Coq",
"ZArith",
"FreeSpec",
"Core",
"CoreFacts"
] | [
"DRAM",
"STORE",
"VGA",
"compliant_semantics",
"correct_component_derives_compliant_semantics",
"derive_semantics",
"dram_o_callee",
"dram_specs",
"mc_specs",
"memory_controller",
"memory_controller_respectful",
"memory_view",
"repeat",
"semantics",
"simpl_tuple",
"smram_pred",
"ssub... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
COUNTER : interface | :=
| Get : COUNTER nat
| Inc : COUNTER unit
| Dec : COUNTER unit. | Inductive | COUNTER | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"interface"
] | The goal of this file is to provide a simple test case for [prove_impure]
and [unroll_respectful_run]. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
counter_get `{Provide ix COUNTER} : impure ix nat | :=
request Get. | Definition | counter_get | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER",
"Provide",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
counter_inc `{Provide ix COUNTER} : impure ix unit | :=
request Inc. | Definition | counter_inc | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER",
"Provide",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
counter_dec `{Provide ix COUNTER} : impure ix unit | :=
request Dec. | Definition | counter_dec | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER",
"Provide",
"impure",
"request"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | repeat | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | update_counter | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | counter_o_caller | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | counter_o_callee | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
counter_specs : contract COUNTER nat | :=
{| witness_update := update_counter
; caller_obligation := counter_o_caller
; callee_obligation := counter_o_callee
|}. | Definition | counter_specs | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER",
"contract",
"counter_o_callee",
"counter_o_caller",
"update_counter"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
dec_then_inc `{Provide ix COUNTER} (x y : nat) : impure ix nat | :=
repeat x counter_dec;;
repeat y counter_inc;;
counter_get. | Definition | dec_then_inc | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER",
"Provide",
"counter_dec",
"counter_get",
"counter_inc",
"impure",
"repeat"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 Lt.lt_pred.
+ clear init_cpt hpost cpt.
revert ω; induction y; intros cpt; prove impure.
Qed. | Theorem | dec_then_inc_respectful | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"COUNTER",
"Provide",
"counter_specs",
"dec_then_inc",
"impure",
"to_hoare"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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.
lia.
Qed. | Lemma | repeat_dec_cpt_output | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"counter_dec",
"counter_specs",
"repeat",
"to_hoare",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Lemma | repeat_inc_cpt_output | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"counter_inc",
"counter_specs",
"repeat",
"to_hoare",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Lemma | get_cpt_output | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"counter_get",
"counter_specs",
"to_hoare",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Theorem | dec_then_inc_cpt_output | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"counter_specs",
"dec_then_inc",
"get_cpt_output",
"repeat_dec_cpt_output",
"repeat_inc_cpt_output",
"to_hoare",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | dec_then_inc_output | tests | tests/core_tactics.v | [
"FreeSpec.Core",
"CoreFacts",
"Coq",
"Lia"
] | [
"counter_specs",
"dec_then_inc",
"to_hoare",
"unroll_post"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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. | Fixpoint | enum | tests | tests/program_fixpoint.v | [
"FreeSpec.Exec",
"Exec",
"Eval",
"Coq.Program",
"Wf",
"Coq",
"List",
"ListNotations"
] | [
"impure"
] | [Exec] and the Coq’s Program framework do not always play nicely
together. The computation of proofs induced by the framework, for instance
to assert well-founded recursion, can make [Exec] very slow by default. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
(i1 i2 i3 i4 : interface). | Axioms | i1 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"interface"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | ||
p1 : forall `{Provide ix}, impure ix nat. | Axiom | p1 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"Provide",
"impure"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | ||
p2 : forall `{Provide2 ix i3 i1}, impure ix nat. | Axiom | p2 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"i1",
"impure"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | ||
p `{Provide4 ix i1 i4 i3 i2} : impure ix nat | :=
p1;;
p2. | Definition | p | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"i1",
"impure",
"p1",
"p2"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
provide_notation_test_1 {a} `{StrictProvide3 ix i1 i2 i3} (p : i2 a) : ix a | :=
inj_p p. | Definition | provide_notation_test_1 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"i1"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
provide_notation_test_2 `{StrictProvide3 ix i1 i2 i3} : StrictProvide2 ix i2 i3. | Proof.
typeclasses eauto.
Qed. | Lemma | provide_notation_test_2 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"i1"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
provide_notation_test_3 {a} (i1 i2 i3 : interface) (p : i2 a) : (iplus (iplus i1 i2) i3) a | :=
inj_p p. | Definition | provide_notation_test_3 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"i1",
"interface",
"iplus"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
provide_notation_test_4 (i1 i2 i3 : interface) : Provide (i1 + (i2 + i3)) i2. | Proof.
typeclasses eauto.
Qed. | Lemma | provide_notation_test_4 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"Provide",
"i1",
"interface"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
provide_notation_test_5 (i1 i2 i3 : interface) : StrictProvide2 (i1 + i2 + i3) i2 i1. | Proof.
typeclasses eauto.
Qed. | Lemma | provide_notation_test_5 | tests | tests/provide_notation.v | [
"FreeSpec.Core",
"Core"
] | [
"i1",
"interface"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
component (i j : interface) : Type | :=
forall (α : Type), i α -> impure j α. | Definition | component | Core | theories/Core/Component.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Interface",
"Semantics",
"Impure"
] | [
"impure",
"interface"
] | In FreeSpec, a _component_ is an entity which exposes an interface [i],
and uses primitives of an interface [j] to compute the results of primitives
of [i]. Besides, a component is likely to carry its own internal state (of
type [s]).
<<
i +-------------------+ j
... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
derive_semantics {i j} (c : component i j) (sem : semantics j)
: semantics i | :=
mk_semantics (fun a p =>
let (res, next) := runState (to_state $ c a p) sem in
(res, derive_semantics c next)). | CoFixpoint | derive_semantics | Core | theories/Core/Component.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Interface",
"Semantics",
"Impure"
] | [
"component",
"semantics",
"to_state"
] | * Semantics Derivation | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
bootstrap {i} (c : component i iempty) : semantics i | :=
derive_semantics c iempty_semantics. | Definition | bootstrap | Core | theories/Core/Component.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Interface",
"Semantics",
"Impure"
] | [
"component",
"derive_semantics",
"iempty",
"iempty_semantics",
"semantics"
] | So, [semprod] on the one hand allows for composing operational semantics
horizontally, and [derive_semantics] allows for composing components
vertically. Using these two operators, we can model a complete system in a
hierarchical and modular manner, by defining each of its components
independently, the... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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 | with_component_aux | Core | theories/Core/Component.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Interface",
"Semantics",
"Impure"
] | [
"component",
"impure"
] | 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 impure computations, i.e., a component.
of type [c : compoment j ix s]. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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 | with_component | Core | theories/Core/Component.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Interface",
"Semantics",
"Impure"
] | [
"component",
"impure",
"with_component_aux"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
derive_semantics' {i j} (c : component i j) (sem : semantics j)
: semantics i | :=
mk_semantics (fun a p =>
(evalState (to_state $ c a p) sem,
derive_semantics' c (execState (to_state $ c a p) sem))). | CoFixpoint | derive_semantics' | Core | theories/Core/ComponentFacts.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Contract",
"HoareFacts",
"SemanticsFacts",
"InstrumentFacts",
"FreeSpec",
"Component"
] | [
"component",
"semantics",
"to_state"
] | We use an alternative definition of [derive_semantics], which has
the virtue of being easier to reason with. More precisely, it
behaves better with evaluation tactics such as [cbn] (according to
our experience, [derive_semantics] requires explicit [destruct]
call to deal with the [let ... in ...] const... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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;
destruct runState.
+ reflexivity.
+ apply aux.
Qed. | Remark | derive_semantics_equ | Core | theories/Core/ComponentFacts.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Contract",
"HoareFacts",
"SemanticsFacts",
"InstrumentFacts",
"FreeSpec",
"Component"
] | [
"component",
"derive_semantics",
"derive_semantics'",
"eval_effect",
"exec_effect",
"run_effect",
"semantics"
] | We prove these two definitions ([derive_semantics] and
[derive_semantics']) are equivalent wrt. [semantics_eq]. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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 $ c α e) ωj x ωj'),
callee_obligation ci ωi e x /\ pred (witness_update ci ωi e x) ωj'. | Definition | correct_component | Core | theories/Core/ComponentFacts.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Contract",
"HoareFacts",
"SemanticsFacts",
"InstrumentFacts",
"FreeSpec",
"Component"
] | [
"MayProvide",
"component",
"contract",
"to_hoare"
] | We consider a component [c : component i j s], meaning [c] exposes an
interface [i], uses an interface [j], and carries an internal state of type
[s].
<<
c : component i j s
i +---------------------+ j
| | | ... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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)
... | Proof.
rewrite derive_semantics_equ.
revert ωi ωj inv sem comp.
cofix correct_component_derives_compliant_semantics.
intros ωi ωj inv sem comp.
unfold correct_component in correct.
specialize (correct ωi ωj inv).
constructor; intros a e req; specialize (correct a e req);
destruct correct as [trust run... | Lemma | correct_component_derives_compliant_semantics | Core | theories/Core/ComponentFacts.v | [
"ExtLib",
"StateMonad",
"FreeSpec.Core",
"Contract",
"HoareFacts",
"SemanticsFacts",
"InstrumentFacts",
"FreeSpec",
"Component"
] | [
"MayProvide",
"compliant_semantics",
"component",
"contract",
"correct_component",
"derive_semantics",
"derive_semantics_equ",
"instrument_preserves_compliance",
"instrument_satisfies_hoare",
"instrument_to_state_eval_morphism",
"instrument_to_state_exec_morphism",
"semantics"
] | Once we have proven [c] is correct wrt. to [speci] and [specj] with [pred]
acting as an invariant throughout [c] life, we show we can derive a
semantics from [c] with an initial state [st] which complies to [speci] in
accordance to [ωi] if we use a semantics of [j] which complies to [specj] in
accordanc... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
contract (i : interface) (Ω : Type) : Type | := make_contract
{ witness_update (ω : Ω) : forall (α : Type), i α -> α -> Ω
; caller_obligation (ω : Ω) : forall (α : Type), i α -> Prop
; callee_obligation (ω : Ω) : forall (α : Type), i α -> α -> Prop
}. | Record | contract | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [
"interface"
] | A contract dedicated to [i : interface] primarily provides two
predicates.
- [caller_obligation] distinguishes between primitives that can be used (by
an impure computation), and primitives that cannot be used.
- [callee_obligation] specifies which guarantees can be expected from
primitives res... | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
const_witness {i} | :=
fun (u : unit) (α : Type) (e : i α) (x : α) => u. | Definition | const_witness | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [] | The most simple contract we can define is the one that requires
anything both for the impure computations which uses the primitives of a
given interface, and for the operational semantics which compute results for
these primitives. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
no_caller_obligation {i Ω} (ω : Ω) (α : Type) (e : i α) : Prop | :=
| mk_no_caller_obligation : no_caller_obligation ω α e. | Inductive | no_caller_obligation | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
no_callee_obligation {i Ω} (ω : Ω) (α : Type) (e : i α) (x : α) : Prop | :=
| mk_no_callee_obligation : no_callee_obligation ω α e x. | Inductive | no_callee_obligation | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
no_contract (i : interface) : contract i unit | :=
{| witness_update := const_witness
; caller_obligation := no_caller_obligation
; callee_obligation := no_callee_obligation
|}. | Definition | no_contract | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [
"const_witness",
"contract",
"interface",
"no_callee_obligation",
"no_caller_obligation"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
do_no_use {i Ω} (ω : Ω) (α : Type) (e : i α) : Prop | := False. | Definition | do_no_use | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [] | A similar —and as simple— contract is the one that forbids the use of a
given interface. | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
forbid_specs (i : interface) : contract i unit | :=
{| witness_update := const_witness
; caller_obligation := do_no_use
; callee_obligation := no_callee_obligation
|}. | Definition | forbid_specs | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [
"const_witness",
"contract",
"do_no_use",
"interface",
"no_callee_obligation"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | contract_caller_equ | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [
"contract"
] | * Contract Equivalence | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
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 | contract_callee_equ | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [
"contract"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 | |
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 | contract_witness_equ | Core | theories/Core/Contract.v | [
"Coq",
"Setoid",
"Morphisms",
"ExtLib",
"StateMonad",
"MonadState",
"MonadTrans",
"FreeSpec.Core",
"Interface",
"Impure",
"Semantics",
"Component"
] | [
"contract"
] | https://github.com/lthms/FreeSpec | d4e2f3a3fc7e82effddca202a8b0210dbbcf3663 |
Structured dataset from FreeSpec — Modular verification of effectful programs.
d4e2f3a3fc7e82effddca202a8b0210dbbcf3663| Column | Type | Description |
|---|---|---|
| statement | string | Declaration signature/claim with the leading keyword removed (verbatim slice); the full declaration minus its proof |
| proof | string | Verbatim proof/body, empty if the declaration has none |
| type | string | Declaration keyword |
| symbolic_name | string | Declaration identifier |
| library | string | Sub-library |
| filename | string | Repository-relative source path |
| imports | list[string] | File-level Require/Import modules |
| deps | list[string] | Intra-corpus identifiers referenced |
| docstring | string | Preceding documentation comment, empty if absent |
| source_url | string | Upstream repository |
| commit | string | Upstream commit extracted |
| Type | Count |
|---|---|
| Definition | 90 |
| Instance | 46 |
| Lemma | 43 |
| Inductive | 24 |
| Ltac | 10 |
| Remark | 6 |
| Fixpoint | 5 |
| Theorem | 4 |
| CoFixpoint | 4 |
| Notation | 3 |
| Class | 3 |
| CoInductive | 3 |
| Axiom | 2 |
| Record | 2 |
| Parameters | 1 |
| Coercion | 1 |
| Axioms | 1 |
open_door `{Provide ix DOORS} (d : door) : impure ix unit
:=
let* open := is_open d in
when (negb open) (toggle d).
open_door | examples/airlock.vEach declaration is split into a statement (signature/claim) and a proof (body) that are disjoint
and together form the complete declaration, for proof modeling, autoformalization, retrieval, and
dependency analysis via deps.
@misc{coq_freespec_dataset,
title = {Coq-FreeSpec},
author = {Norton, Charles},
year = {2026},
note = {Extracted from https://github.com/lthms/FreeSpec, commit d4e2f3a3fc7e},
url = {https://huggingface.co/datasets/phanerozoic/Coq-FreeSpec}
}