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

Wrong model printing for arrays #555

Closed
Halbaroth opened this issue Mar 31, 2023 · 3 comments · Fixed by #659
Closed

Wrong model printing for arrays #555

Halbaroth opened this issue Mar 31, 2023 · 3 comments · Fixed by #659
Assignees
Labels
Milestone

Comments

@Halbaroth
Copy link
Collaborator

Halbaroth commented Mar 31, 2023

Alt-Ergo (next - 963e40c) doesn't print correctly the model for the following input file:

(set-logic ALL)
(declare-const x Int)
(declare-const y Int)
(declare-const a1 (Array Int Int))
(declare-const a2 (Array Int Int))
(assert (= (select a1 x) x))
(assert (= (store a1 x y) a1))
(check-sat)
(get-model)

The actual model:

unknown

(model
  
 ; Functions

 ; Constants

(define-fun a1 () (Array Int Int) a1)

(define-fun x () Int 0)

(define-fun y () Int 0)

 ; Arrays not yet supported


)

unknown
@Halbaroth Halbaroth added the bug label Mar 31, 2023
@Halbaroth Halbaroth added this to the 2.6.0 milestone Mar 31, 2023
@Gbury

This comment was marked as outdated.

@Gbury
Copy link
Collaborator

Gbury commented Mar 31, 2023

Rather, a model would be any assignment where:

  • x = y
  • a1 binds x to x

@hra687261
Copy link
Contributor

The model is not wrong. It's printing is wrong. Since x = y = 0 and a1 binds x to y.
The printing should look something like what Z3 produces:

sat
(
  (define-fun a1 () (Array Int Int)
    (store ((as const (Array Int Int)) 2) 3 3))
  (define-fun x () Int
    3)
  (define-fun y () Int
    3)
  (define-fun a2 () (Array Int Int)
    ((as const (Array Int Int)) 0))
)
(
  (define-fun a1 () (Array Int Int)
    (store ((as const (Array Int Int)) 2) 3 3))
  (define-fun x () Int
    3)
  (define-fun y () Int
    3)
  (define-fun a2 () (Array Int Int)
    ((as const (Array Int Int)) 0))
)

A default value with const, plus a set of bindings with stores.
Can you fix the text of the issue?

@Halbaroth Halbaroth changed the title Wrong model generated for arrays Wrong model printing for arrays Apr 2, 2023
@Halbaroth Halbaroth modified the milestones: 2.6.0, 2.5.0 Jun 6, 2023
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Jun 16, 2023
This patch adds the support for printing arrays in the models output.
Rather than printing default values, we print smtlib abstract values
(@xxx) for the unknown elements, because we don't have a default value
available easily otherwise.

The example model in OCamlPro#555 now displays as:

```smtlib2
(
  (define-fun x () Int 0)
  (define-fun y () Int 0)
  (define-fun a1 () (Array Int Int) (store (as @A1 (Array Int Int)) 0 0))
)
```

This also removes the "Functions" / "Constants" / "Arrays" sections
because they were now wrong (some arrays were in constants, other in
arrays) and hence somewhat confusing. Instead, the "values" section is
added then printing with `--model-type constraints`.

Uses of Printer.print_fmt have also been replaced with Format.fprintf
because they were causing weird looking outputs with some combinations
of options. Only the final value is printer with `print_fmt`, which
should do the appropriate (actually, I don't think it is needed here,
but better safe than sorry) cleanup dance only once.

Fixes OCamlPro#555
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Jun 27, 2023
This patch adds the support for printing arrays in the models output.
Rather than printing default values, we print smtlib abstract values
(@xxx) for the unknown elements, because we don't have a default value
available easily otherwise.

The example model in OCamlPro#555 now displays as:

```smtlib2
(
  (define-fun x () Int 0)
  (define-fun y () Int 0)
  (define-fun a1 () (Array Int Int) (store (as @A1 (Array Int Int)) 0 0))
)
```

This also removes the "Functions" / "Constants" / "Arrays" sections
because they were now wrong (some arrays were in constants, other in
arrays) and hence somewhat confusing. Instead, the "values" section is
added then printing with `--model-type constraints`.

Uses of Printer.print_fmt have also been replaced with Format.fprintf
because they were causing weird looking outputs with some combinations
of options. Only the final value is printer with `print_fmt`, which
should do the appropriate (actually, I don't think it is needed here,
but better safe than sorry) cleanup dance only once.

Fixes OCamlPro#555
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Jun 27, 2023
This patch adds the support for printing arrays in the models output.
Rather than printing default values, we print smtlib abstract values
(@xxx) for the unknown elements, because we don't have a default value
available easily otherwise.

The example model in OCamlPro#555 now displays as:

```smtlib2
(
  (define-fun x () Int 0)
  (define-fun y () Int 0)
  (define-fun a1 () (Array Int Int) (store (as @A1 (Array Int Int)) 0 0))
)
```

This also removes the "Functions" / "Constants" / "Arrays" sections
because they were now wrong (some arrays were in constants, other in
arrays) and hence somewhat confusing. Instead, the "values" section is
added then printing with `--model-type constraints`.

Uses of Printer.print_fmt have also been replaced with Format.fprintf
because they were causing weird looking outputs with some combinations
of options. Only the final value is printer with `print_fmt`, which
should do the appropriate (actually, I don't think it is needed here,
but better safe than sorry) cleanup dance only once.

Fixes OCamlPro#555
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Jun 29, 2023
This patch adds the support for printing arrays in the models output.
Rather than printing default values, we print smtlib abstract values
(@xxx) for the unknown elements, because we don't have a default value
available easily otherwise.

The example model in OCamlPro#555 now displays as:

```smtlib2
(
  (define-fun x () Int 0)
  (define-fun y () Int 0)
  (define-fun a1 () (Array Int Int) (store (as @A1 (Array Int Int)) 0 0))
)
```

This also removes the "Functions" / "Constants" / "Arrays" sections
because they were now wrong (some arrays were in constants, other in
arrays) and hence somewhat confusing. Instead, the "values" section is
added then printing with `--model-type constraints`.

Uses of Printer.print_fmt have also been replaced with Format.fprintf
because they were causing weird looking outputs with some combinations
of options. Only the final value is printer with `print_fmt`, which
should do the appropriate (actually, I don't think it is needed here,
but better safe than sorry) cleanup dance only once.

Fixes OCamlPro#555
bclement-ocp added a commit that referenced this issue Jun 29, 2023
This patch adds the support for printing arrays in the models output.
Rather than printing default values, we print smtlib abstract values
(@xxx) for the unknown elements, because we don't have a default value
available easily otherwise.

The example model in #555 now displays as:

```smtlib2
(
  (define-fun x () Int 0)
  (define-fun y () Int 0)
  (define-fun a1 () (Array Int Int) (store (as @A1 (Array Int Int)) 0 0))
)
```

This also removes the "Functions" / "Constants" / "Arrays" sections
because they were now wrong (some arrays were in constants, other in
arrays) and hence somewhat confusing. Instead, the "values" section is
added then printing with `--model-type constraints`.

Uses of Printer.print_fmt have also been replaced with Format.fprintf
because they were causing weird looking outputs with some combinations
of options. Only the final value is printer with `print_fmt`, which
should do the appropriate (actually, I don't think it is needed here,
but better safe than sorry) cleanup dance only once.

Fixes #555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants