Skip to content

Add assertion levels in SatML#1297

Merged
Halbaroth merged 1 commit into
OCamlPro:nextfrom
Halbaroth:assertion-level
Feb 17, 2025
Merged

Add assertion levels in SatML#1297
Halbaroth merged 1 commit into
OCamlPro:nextfrom
Halbaroth:assertion-level

Conversation

@Halbaroth

@Halbaroth Halbaroth commented Feb 17, 2025

Copy link
Copy Markdown
Collaborator

Satml_frontend assumes that assume and check_sat are always called on a SatML environment with no prior decisions. It works in the current codebase because, in the presence of pop/push, we always restart from a fresh environment.

This PR is a preparation for #1288.

The assertion:

assert (SAT.decision_level env.satml == 0)

is replaced with:

assert (SAT.decision_level env.satml <= SAT.assertion_level env.satml)

Notice that we cannot enforce the assertion:

assert (SAT.decision_level env.satml = SAT.assertion_level env.satml)

Consider for instance:

let env = SAT.env () in
SAT.push env 1;
SAT.assume env f; (* <--- HERE *)
...

Internally, SAT.assume env f adds the formula g => f into the environment of SatML where g is a guard formula introduced in SAT.push. But SatML.assume does not decide the guard formula g, so the decision level is 0 but the assertion level is 1. Guards are decided (with the highest priority) in SatML.solve, and is called by SAT.unsat.

I didn't add the new assertion into SAT.assume_th_elt because this function is only used for handling the theory concept in native language and we always invoke it at the assertion level 0.

`Satml_frontend` assumes that `assume` and `check_sat` are always called
on a SatML environment with no prior decisions. It works in the current
codebase because, in the presence of pop/push, we always restart from a
fresh environment.

The assertion:
```ocaml
assert (SAT.decision_level env.satml == 0)
```
is replaced with:
```ocaml
assert (SAT.decision_level env.satml <= SAT.assertion_level env.satml)
```

Notice that we cannot enforce the assertion:
```ocaml
assert (SAT.decision_level env.satml = SAT.assertion_level env.satml)
```
Consider for instance:
```ocaml
let env = SAT.env () in
SAT.push env 1;
SAT.assume env f; (* <--- HERE *)
...
```
Internally, `SAT.assume env f` adds the formula `g => f` into the
environment of SatML where `g` is a guard formula introduced in
`SAT.push`. But `SatML.assume` does not decide the guard formula [g], so
the decision level is 0 but the assertion level is 1.
Guards are decided (with the highest priority) in `SatML.solve`, which
is called by `SAT.unsat`.

I didn't add the new assertion into `SAT.assume_th_elt` because this
function is only used for handling the theory concept in native language and
we always invoke it at the assertion level 0.
@Halbaroth Halbaroth added frontend SAT Relates to the SAT solvers labels Feb 17, 2025
@Halbaroth Halbaroth merged commit cbe944f into OCamlPro:next Feb 17, 2025
@Halbaroth Halbaroth mentioned this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend SAT Relates to the SAT solvers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants