Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete model #1019

Merged
merged 13 commits into from
Jan 18, 2024
Merged

Complete model #1019

merged 13 commits into from
Jan 18, 2024

Commits on Jan 17, 2024

  1. Configuration menu
    Copy the full SHA
    b29a119 View commit details
    Browse the repository at this point in the history
  2. Generate complete model

    This PR fixes the issue OCamlPro#778. The suggested solution by this PR is as follows:
    - Collect user-declared symbols in `D_cnf`;
    - As the function `make` of the module `D_cnf` returns a list of
      commands, we add a new command `Decl` in `Frontend` to declare
      symbols;
    - The declared symbols are given to the SAT solver through a new
      function `declaration` in `sat_solver_sig`.
    - These symbols are collected in vectors and we keep indexes in another
      PR in order to manage properly the push/pop mechanism.
    - Finally the declared symbols are given to `Uf` and we create the empty
      model with them.
    
    Another annoying point comes from the current datastructure used in
    `ModelMap`. The type of `ModelMap` saves model values in the form of graphs.
    A graph is a finite set of constraints but there is no appropriate
    representation for the graph without constraints. Let's imagine we have
    the input:
    ```smt2
    (set-option :produce-models true)
    (set-logic ALL)
    (declare-fun (Int) Int)
    (check-sat)
    (get-model)
    ```
    We expect an output as follows:
    ```smt2
    (
      (define-fun f (_x Int) (@A as Int))
    )
    ```
    But `Graph.empty` cannot hold the abstract value `@a`. A naive solution
    consists in using an ADT:
    ```ocaml
    type graph =
    | Empty of Id.typed
    | G of Graph.t
    ```
    But we'll add an extra indirection. Probably the best solution would be
    to use a custom datastructure instead of a map to store the constraints.
    In this PR, we detect in `ModelMap.add` if the only constraint in the
    graph is of the form `something -> abstract value`. In this case we
    remove this constraint.
    
    This solution isn't perfect as explained in issue OCamlPro#1018. The biggest
    drawback of this solution is the fact we have to declare symbols in the
    SAT API, otherwise models returned by `get_model` could be
    incomplete.
    Halbaroth committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    959bf7b View commit details
    Browse the repository at this point in the history
  3. Move comment

    Halbaroth committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    8a556a4 View commit details
    Browse the repository at this point in the history
  4. Remove useless option

    Halbaroth committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    3e2d501 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6e499aa View commit details
    Browse the repository at this point in the history
  6. We aren't in C++ :)

    Halbaroth committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    02208a1 View commit details
    Browse the repository at this point in the history
  7. Split the test

    Halbaroth committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    e07bfa0 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b073017 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ad415e5 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    14e729d View commit details
    Browse the repository at this point in the history
  11. Avoid list concatenation

    Halbaroth committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    c65d8f2 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    359ac56 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    98899b9 View commit details
    Browse the repository at this point in the history