Skip to content

Commit 0291774

Browse files
committed
feat lib/mir: add Decl, Db_op, make Db_ser a list of ops
1 parent f597a64 commit 0291774

File tree

5 files changed

+62
-30
lines changed

5 files changed

+62
-30
lines changed

src/lib/common/db_op.ml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
(** Operations that modify {!Db.t}. These can be sent on the network. *)
2+
type ('term, 'ty) t_poly =
3+
| Op_enable of Imandrax_api.Uid.t list
4+
| Op_disable of Imandrax_api.Uid.t list
5+
| Op_add_decls of ('term, 'ty) Decl.t_poly list
6+
| Op_add_rw of 'ty Pattern_head.t_poly * ('term, 'ty) Rewrite_rule.t_poly
7+
| Op_add_fc_trigger of 'ty Pattern_head.t_poly * 'ty Trigger.t_poly
8+
| Op_add_elim of
9+
'ty Pattern_head.t_poly * ('term, 'ty) Elimination_rule.t_poly
10+
| Op_add_gen_trigger of 'ty Pattern_head.t_poly * 'ty Trigger.t_poly
11+
| Op_add_count_fun of Imandrax_api.Uid.t * ('term, 'ty) Fun_def.t_poly
12+
| Op_set_admission of Imandrax_api.Uid.t * Admission.t
13+
| Op_set_thm_as_rw of
14+
Imandrax_api.Uid.t * ('term, 'ty) Rewrite_rule.t_poly list
15+
| Op_set_thm_as_fc of
16+
Imandrax_api.Uid.t * ('term, 'ty) Instantiation_rule.t_poly list
17+
| Op_set_thm_as_elim of
18+
Imandrax_api.Uid.t * ('term, 'ty) Elimination_rule.t_poly list
19+
| Op_set_thm_as_gen of
20+
Imandrax_api.Uid.t * ('term, 'ty) Instantiation_rule.t_poly
21+
| Op_add_instantiation_rule of ('term, 'ty) Instantiation_rule.t_poly
22+
| Op_add_rule_spec_fc_triggers of Imandrax_api.Uid.t * 'ty Trigger.t_poly list
23+
| Op_add_rule_spec_rw of
24+
Imandrax_api.Uid.t * ('term, 'ty) Rewrite_rule.t_poly list
25+
[@@deriving show { with_path = false }, twine, map, iter]

src/lib/common/db_ser.ml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,12 @@
11
(** A serializable logic database. It contains all relevant context for proof
22
obligations. *)
33

4-
type 'a uid_map = (Imandrax_api.Uid.t * 'a) list
5-
[@@deriving show, twine, typereg]
6-
7-
type ('ty, 'a) ph_map = ('ty Pattern_head.t_poly * 'a) list
8-
[@@deriving show, twine, typereg, map, iter]
9-
104
type 'a ca_ptr = 'a Imandrax_api_ca_store.Ca_ptr.t [@@deriving twine, typereg]
115

126
open struct
137
let pp_ca_ptr _ out c = Imandrax_api_ca_store.Ca_ptr.pp out c
148
end
159

16-
type ('term, 'ty) t_poly = {
17-
cname_decls: Imandrax_api.Uid_set.t; (** declarations by cname/cptr *)
18-
local_tys: 'ty Imandrax_api.Ty_view.def_poly list;
19-
(** type declarations included here *)
20-
local_funs: ('term, 'ty) Fun_def.t_poly list;
21-
(** function declarations included here *)
22-
rw_rules: ('ty, ('term, 'ty) Rewrite_rule.t_poly ca_ptr list) ph_map;
23-
inst_rules: ('term, 'ty) Instantiation_rule.t_poly ca_ptr uid_map;
24-
rule_spec_fc: 'ty Trigger.t_poly ca_ptr list uid_map;
25-
rule_spec_rw_rules: ('term, 'ty) Rewrite_rule.t_poly ca_ptr list uid_map;
26-
fc: ('ty, 'ty Trigger.t_poly ca_ptr list) ph_map;
27-
elim: ('ty, ('term, 'ty) Elimination_rule.t_poly ca_ptr list) ph_map;
28-
gen: ('ty, 'ty Trigger.t_poly ca_ptr list) ph_map;
29-
thm_as_rw: ('term, 'ty) Rewrite_rule.t_poly ca_ptr list uid_map;
30-
thm_as_fc: ('term, 'ty) Instantiation_rule.t_poly ca_ptr list uid_map;
31-
thm_as_elim: ('term, 'ty) Elimination_rule.t_poly ca_ptr list uid_map;
32-
thm_as_gen: ('term, 'ty) Instantiation_rule.t_poly ca_ptr list uid_map;
33-
admission: Admission.t ca_ptr uid_map;
34-
count_funs_of_ty: Imandrax_api.Uid.t uid_map;
35-
(** Type -> count function for it *)
36-
disabled: Imandrax_api.Uid_set.t;
37-
}
10+
type ('term, 'ty) t_poly = { ops: ('term, 'ty) Db_op.t_poly ca_ptr list }
3811
[@@deriving show { with_path = false }, twine, typereg]
3912
(** A serializable logic database. *)
40-
41-
(* NOTE: this is not deriving map because we can't map through a ca_ptr. *)

src/lib/common/decl.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type ('term, 'ty) t_poly =
2+
| Fun of ('term, 'ty) Fun_def.t_poly
3+
| Ty of 'ty Imandrax_api.Ty_view.def_poly
4+
| Theorem of ('term, 'ty) Theorem.t_poly
5+
| Rule_spec of ('term, 'ty) Rule_spec.t_poly
6+
| Verify of ('term, 'ty) Verify.t_poly
7+
[@@deriving show { with_path = false }, map, iter, twine]

src/lib/common/rule_spec.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
type ('term, 'ty) t_poly = {
2+
rule_spec_fc: bool; (** forward chaining rule? *)
3+
rule_spec_rewriting: bool; (** rewrite rule? *)
4+
rule_spec_perm_restrict: bool;
5+
(** apply permutative rewrite rule restrictions? *)
6+
rule_spec_link: ('term, 'ty) Fun_def.t_poly;
7+
(** corresponding (boolean) function *)
8+
rule_spec_triggers: 'term Pre_trigger.t_poly list;
9+
(** explicit rule triggers *)
10+
}
11+
[@@deriving twine, map, iter, show { with_path = false }]
12+
(** A rule_spec_spec, entered with
13+
[rule_spec_spec foo x y = <formula using x,y>] *)
14+
15+
let name self = self.rule_spec_link.f_name

src/lib/common/verify.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
type ('term, 'ty) t_poly = {
2+
verify_link: ('term, 'ty) Fun_def.t_poly;
3+
(** nameless function representing the property to check *)
4+
verify_simplify: bool; (** simplify first? *)
5+
verify_nonlin: bool; (** nonlinear real arithmetic? *)
6+
verify_upto: Imandrax_api.Upto.t option;
7+
verify_is_instance: bool;
8+
verify_minimize: 'term list; (** arithmetic terms to minimize in models *)
9+
verify_by: ('ty Var.t_poly list * 'term) option;
10+
}
11+
[@@deriving twine, iter, map, show { with_path = false }]
12+
(** A [verify (fun x y -> <formula using x,y>)] event, for nameless theorems. *)
13+
14+
let name self = self.verify_link.f_name

0 commit comments

Comments
 (0)