diff options
| author | Rutger Broekhoff | 2025-07-07 21:52:08 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2025-07-07 21:52:08 +0200 |
| commit | ba61dfd69504ec6263a9dee9931d93adeb6f3142 (patch) | |
| tree | d6c9b78e50eeab24e0c1c09ab45909a6ae3fd5db /lib/extraction | |
| download | verified-dyn-lang-interp-ba61dfd69504ec6263a9dee9931d93adeb6f3142.tar.gz verified-dyn-lang-interp-ba61dfd69504ec6263a9dee9931d93adeb6f3142.zip | |
Initialize repository
Diffstat (limited to 'lib/extraction')
| -rw-r--r-- | lib/extraction/dune | 56 | ||||
| -rw-r--r-- | lib/extraction/extraction.ml | 18 | ||||
| -rw-r--r-- | lib/extraction/prelude.v | 52 |
3 files changed, 126 insertions, 0 deletions
diff --git a/lib/extraction/dune b/lib/extraction/dune new file mode 100644 index 0000000..b56caf9 --- /dev/null +++ b/lib/extraction/dune | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | (coq.extraction | ||
| 2 | (prelude prelude) | ||
| 3 | (extracted_modules | ||
| 4 | Ascii | ||
| 5 | BinInt | ||
| 6 | Bits | ||
| 7 | Decimal | ||
| 8 | prelude | ||
| 9 | gmap | ||
| 10 | Nat | ||
| 11 | PeanoNat | ||
| 12 | SpecFloat | ||
| 13 | ZArith_dec | ||
| 14 | base | ||
| 15 | BinNat | ||
| 16 | Bool | ||
| 17 | DecimalString | ||
| 18 | interp | ||
| 19 | numbers | ||
| 20 | pretty | ||
| 21 | Specif | ||
| 22 | Zbool | ||
| 23 | Basics | ||
| 24 | BinNums | ||
| 25 | countable | ||
| 26 | list0 | ||
| 27 | operational | ||
| 28 | res | ||
| 29 | String | ||
| 30 | Zpower | ||
| 31 | Binary | ||
| 32 | BinPosDef | ||
| 33 | Datatypes | ||
| 34 | fin_maps | ||
| 35 | List | ||
| 36 | option | ||
| 37 | Round | ||
| 38 | strings | ||
| 39 | BinarySingleNaN | ||
| 40 | BinPos | ||
| 41 | decidable | ||
| 42 | floats | ||
| 43 | mapset | ||
| 44 | orders | ||
| 45 | sorting | ||
| 46 | utils) | ||
| 47 | (flags | ||
| 48 | (-output-directory ".")) | ||
| 49 | (theories Flocq stdpp mininix)) | ||
| 50 | |||
| 51 | (library | ||
| 52 | (name extraction) | ||
| 53 | (flags | ||
| 54 | (:standard -w -33)) | ||
| 55 | (instrumentation | ||
| 56 | (backend bisect_ppx))) | ||
diff --git a/lib/extraction/extraction.ml b/lib/extraction/extraction.ml new file mode 100644 index 0000000..a737700 --- /dev/null +++ b/lib/extraction/extraction.ml | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | include Prelude | ||
| 2 | include Interp | ||
| 3 | include Operational | ||
| 4 | include Res | ||
| 5 | |||
| 6 | (* Stuff that's not part of the paper. Still exposed because we sometimes want | ||
| 7 | to be able to create a natural number, float, process a list etc. *) | ||
| 8 | module Internal = struct | ||
| 9 | module BinNums = BinNums | ||
| 10 | module Datatypes = Datatypes | ||
| 11 | module List = List | ||
| 12 | |||
| 13 | module Floats = struct | ||
| 14 | include Floats | ||
| 15 | include Binary | ||
| 16 | include SpecFloat | ||
| 17 | end | ||
| 18 | end | ||
diff --git a/lib/extraction/prelude.v b/lib/extraction/prelude.v new file mode 100644 index 0000000..ef35bcb --- /dev/null +++ b/lib/extraction/prelude.v | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | Require Import Coq.Numbers.DecimalString ExtrOcamlBasic ExtrOcamlString. | ||
| 2 | From stdpp Require Import strings stringmap gmap. | ||
| 3 | From mininix Require Import nix.interp. | ||
| 4 | |||
| 5 | Definition attr_set_insert (x : string) (α : attr) (αs : gmap string attr) : gmap string attr := | ||
| 6 | <[x:=α]> αs. | ||
| 7 | |||
| 8 | Definition attr_set_contains (x : string) (αs : gmap string attr) : bool := | ||
| 9 | bool_decide (x ∈ dom αs). | ||
| 10 | |||
| 11 | Definition attr_set_fold {A} (f : string → attr → A → A) (init : A) (αs : gmap string attr) : A := | ||
| 12 | map_fold f init αs. | ||
| 13 | |||
| 14 | Definition attr_set_empty : gmap string attr := ∅. | ||
| 15 | |||
| 16 | Definition env_fold {A} (f : string → (kind * thunk) → A → A) (init : A) (E : env) : A := | ||
| 17 | map_fold f init E. | ||
| 18 | |||
| 19 | Definition env_insert_abs (x : string) (t : thunk) (E : env) : env := | ||
| 20 | <[x:=(ABS,t)]> E. | ||
| 21 | |||
| 22 | Definition thunk_map_fold {A} (f : string → thunk → A → A) (init : A) (bs : gmap string thunk) : A := | ||
| 23 | map_fold f init bs. | ||
| 24 | |||
| 25 | Definition thunk_map_insert (x : string) (t : thunk) (bs : gmap string thunk) : gmap string thunk := | ||
| 26 | <[x:=t]> bs. | ||
| 27 | |||
| 28 | Definition thunk_map_empty : gmap string thunk := ∅. | ||
| 29 | |||
| 30 | Definition matcher := gmap string (option expr). | ||
| 31 | |||
| 32 | Definition matcher_empty : matcher := ∅. | ||
| 33 | |||
| 34 | Definition matcher_insert (x : string) (me : option expr) (ms : matcher) : matcher := | ||
| 35 | <[x:=me]> ms. | ||
| 36 | |||
| 37 | Definition matcher_fold {A} (f : string → option expr → A → A) (init : A) (ms : matcher) : A := | ||
| 38 | map_fold f init ms. | ||
| 39 | |||
| 40 | Definition env_empty : env := ∅. | ||
| 41 | |||
| 42 | Definition string_of_Z (x : Z) : string := | ||
| 43 | NilZero.string_of_int (Z.to_int x). | ||
| 44 | |||
| 45 | Definition string_to_Z (s : string) : option Z := | ||
| 46 | Z.of_int <$> NilZero.int_of_string s. | ||
| 47 | |||
| 48 | Separate Extraction | ||
| 49 | attr_set_insert env_insert_abs matcher_insert thunk_map_insert | ||
| 50 | attr_set_contains attr_set_fold env_fold matcher_fold thunk_map_fold | ||
| 51 | env_empty attr_set_empty matcher_empty thunk_map_empty string_of_Z | ||
| 52 | string_to_Z interp' forallb. | ||