aboutsummaryrefslogtreecommitdiffstats
path: root/lib/extraction
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extraction')
-rw-r--r--lib/extraction/dune56
-rw-r--r--lib/extraction/extraction.ml18
-rw-r--r--lib/extraction/prelude.v52
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 @@
1include Prelude
2include Interp
3include Operational
4include 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. *)
8module 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
18end
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 @@
1Require Import Coq.Numbers.DecimalString ExtrOcamlBasic ExtrOcamlString.
2From stdpp Require Import strings stringmap gmap.
3From mininix Require Import nix.interp.
4
5Definition attr_set_insert (x : string) (α : attr) (αs : gmap string attr) : gmap string attr :=
6 <[x:=α]> αs.
7
8Definition attr_set_contains (x : string) (αs : gmap string attr) : bool :=
9 bool_decide (x ∈ dom αs).
10
11Definition attr_set_fold {A} (f : string → attr → A → A) (init : A) (αs : gmap string attr) : A :=
12 map_fold f init αs.
13
14Definition attr_set_empty : gmap string attr := ∅.
15
16Definition env_fold {A} (f : string → (kind * thunk) → A → A) (init : A) (E : env) : A :=
17 map_fold f init E.
18
19Definition env_insert_abs (x : string) (t : thunk) (E : env) : env :=
20 <[x:=(ABS,t)]> E.
21
22Definition thunk_map_fold {A} (f : string → thunk → A → A) (init : A) (bs : gmap string thunk) : A :=
23 map_fold f init bs.
24
25Definition thunk_map_insert (x : string) (t : thunk) (bs : gmap string thunk) : gmap string thunk :=
26 <[x:=t]> bs.
27
28Definition thunk_map_empty : gmap string thunk := ∅.
29
30Definition matcher := gmap string (option expr).
31
32Definition matcher_empty : matcher := ∅.
33
34Definition matcher_insert (x : string) (me : option expr) (ms : matcher) : matcher :=
35 <[x:=me]> ms.
36
37Definition matcher_fold {A} (f : string → option expr → A → A) (init : A) (ms : matcher) : A :=
38 map_fold f init ms.
39
40Definition env_empty : env := ∅.
41
42Definition string_of_Z (x : Z) : string :=
43 NilZero.string_of_int (Z.to_int x).
44
45Definition string_to_Z (s : string) : option Z :=
46 Z.of_int <$> NilZero.int_of_string s.
47
48Separate 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.