aboutsummaryrefslogtreecommitdiffstats
path: root/lib/program.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 03:15:25 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 03:15:25 -0300
commit40376c3ea009eab4db9ba27837e61d8bec310b8f (patch)
tree725c1e789871f0c34a752f901d056e4007814965 /lib/program.ml
parentc530682030e80ee2de2c263471e5eda7a3392e84 (diff)
downloadSOL-40376c3ea009eab4db9ba27837e61d8bec310b8f.tar.gz
SOL-40376c3ea009eab4db9ba27837e61d8bec310b8f.zip
negation, quantifiers and membership criteria as schema domains
Diffstat (limited to 'lib/program.ml')
-rw-r--r--lib/program.ml40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/program.ml b/lib/program.ml
new file mode 100644
index 0000000..ac62781
--- /dev/null
+++ b/lib/program.ml
@@ -0,0 +1,40 @@
+type error =
+ | Load of World.error
+ | Integrity of { relation : string; label : string }
+ | Undecidable_criterion of { relation : string; label : string }
+
+let pp_error fmt = function
+ | Load error -> World.pp_error fmt error
+ | Integrity { relation; label } ->
+ Format.fprintf fmt "integrity violation on %s at %s:" relation label
+ | Undecidable_criterion { relation; label } ->
+ Format.fprintf fmt "criterion on %s at %s: is not decidable" relation label
+
+let load statements =
+ match World.Standalone.load statements with
+ | Error error -> Error (Load error)
+ | Ok (world, queries, pendings) ->
+ let rec admit = function
+ | [] -> Ok (world, queries)
+ | pending :: rest -> (
+ let { World.pending_relation; pending_label; pending_body } =
+ pending
+ in
+ match Vm.Standalone.solve world pending_body with
+ | Ok (_ :: _) -> admit rest
+ | Ok [] ->
+ Error
+ (Integrity
+ {
+ relation = pending_relation;
+ label = Label.to_string pending_label;
+ })
+ | Error (Vm.Non_total_plan _) ->
+ Error
+ (Undecidable_criterion
+ {
+ relation = pending_relation;
+ label = Label.to_string pending_label;
+ }))
+ in
+ admit pendings