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

Models, rebased #530

Merged
merged 68 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1cf6146
examples and initial draft report
May 27, 2020
ef69040
attempt to fix CI: Seq dep missing to compile lib_usage test file
Dec 27, 2020
8191b22
change version to models
ACoquereau Oct 9, 2020
201986e
models generation: add some examples
May 28, 2020
3659aa7
parent f3ad875887004a069e3e9d9e2f906f2f9dfa040f
Jun 10, 2020
65579f1
check sat handled on the lowest possible level, need to work on unsat…
Jul 2, 2020
6585690
first prototype for models in Why3, lots of hard coded stuff that nee…
ACoquereau Sep 1, 2020
fbe1dcd
Change interpretation option, use mdl-formatter to compute but not pr…
ACoquereau Dec 17, 2020
09fd036
Style check
ACoquereau Oct 9, 2020
e7b13ff
Move the printing of counterexample from uf.ml to models.ml
ACoquereau Oct 16, 2020
0f327c4
Prototype of printer for records in smt format
ACoquereau Oct 16, 2020
b6ac9a1
Directly use rep of bool value for counterexamples
ACoquereau Oct 16, 2020
4ed1c50
fix destr list rev
ACoquereau Oct 16, 2020
e27aad5
Clean choose_adequate_model for boolean constant
ACoquereau Oct 19, 2020
b5ea964
Add `fast` option that disable greedier instantiation phase
ACoquereau Dec 17, 2020
49b0b4b
remove greedier and get_fast in fun_sat
Jan 19, 2021
77ae13a
Prototype to output constraint as model if output is set to why3
ACoquereau Nov 13, 2020
2309ca2
Remove `why3-counter-example` option, use `-o why3` instead
ACoquereau Nov 19, 2020
318e6a5
Code cleaning and addition of functions printing with cascade of ite
ACoquereau Nov 19, 2020
55c5dd2
fix compatibility for ocaml version < 4.07
ACoquereau Nov 20, 2020
c71e7ac
Fix printing of some type in smtlib2 output format
ACoquereau Nov 20, 2020
f4a7607
Add an example which test some ce
ACoquereau Nov 20, 2020
f006f41
Add support for record constuctor use in model
ACoquereau Nov 24, 2020
b0c4e9d
Add option dummy-value for interpretation that output _ instead of du…
ACoquereau Nov 25, 2020
f3a4daf
Fix pp_term and assert output prototype
ACoquereau Nov 25, 2020
b37a951
Add factorisation in ite when values or the same
ACoquereau Nov 25, 2020
6424ea1
reeplace dummy_value with use_underscore option
ACoquereau Nov 26, 2020
2146df9
remove fast option, use `--instantiation-heuristic=normal` instead
ACoquereau Dec 17, 2020
2c7f12b
Copy print expr code in models for better management of named expr
ACoquereau Dec 17, 2020
2faa2ff
[models] add case-split on internal bool terms
Dec 19, 2020
8d0192c
Type Expr.view should remain "private"
Dec 28, 2020
43f53fc
fix intendation
Dec 28, 2020
6721f14
Expr.get_infos returns the view: to avoid uesless tuple allocation
Dec 28, 2020
e2f953d
refactor the way model is output from fun_sat
Dec 2, 2020
590be70
Rename interpretation option values to None First Last and Every
ACoquereau Dec 23, 2020
fc903a9
Fix interpretation_timelimit initialisation
ACoquereau Jan 7, 2021
c812399
auto set option "fm_cross_limit = -1" (ie. infinity) if models-gen is…
Jan 7, 2021
1637918
Fix use_underscore_interpretation option
ACoquereau Jan 8, 2021
0ad94d6
Remove deadcode from models and mv models.ml in frontend
ACoquereau Jan 8, 2021
4dcd462
Add some documentation in options.ml for type model, instanciation_h…
ACoquereau Jan 8, 2021
bd13836
Fix no-term-like-pp option comment
ACoquereau Jan 8, 2021
20074d1
Fix model options
ACoquereau Jan 8, 2021
f0657be
remove unused models-generation code (all, complete and default models)
Jan 8, 2021
8884c62
remove functions related to old model
ACoquereau Jan 8, 2021
3b15a1f
clean unused code
Jan 8, 2021
97635ed
fix linter
Jan 9, 2021
a961b33
Fix frontend output in case of timeout
ACoquereau Jan 8, 2021
388d8c8
Clean models, remove old native output, and remove ref for records
ACoquereau Jan 8, 2021
ebba092
Move profile module from Models module to structures
ACoquereau Jan 8, 2021
51a1394
Fix printing of constraints in why3 output when constraints are func…
ACoquereau Jan 15, 2021
8fd568f
Fix declare-fun command in models
ACoquereau Feb 9, 2021
21438a6
Uses printer instead of format in models comments
ACoquereau Mar 29, 2021
5dba7a0
Better command line arguments
Stevendeo May 19, 2021
0e54017
Style fix
Stevendeo May 19, 2021
771152d
Adding simple model option
Stevendeo Oct 14, 2022
a5e47c6
Rebase artifacts
Stevendeo Oct 14, 2022
d26d938
Putting model option in the right option list
Stevendeo Oct 14, 2022
d83fabe
Poetry
Stevendeo Oct 14, 2022
e2d8c81
Fix parse command
Stevendeo Oct 18, 2022
4b11720
Poetry
Stevendeo Nov 4, 2022
919b98c
Adding a proper exception for unsupported features and removing 'at_e…
Stevendeo Nov 8, 2022
dfdb6c7
Adding doc & some poetry
Stevendeo Nov 10, 2022
205bfe9
Consistent inlining annotations
Stevendeo Nov 14, 2022
c8e6783
Not updating instantiation heuristic in model option
Stevendeo Nov 14, 2022
c890d88
New name for Profile module
Stevendeo Nov 17, 2022
9d85c33
Fix SMTLIB2 printer
Stevendeo Nov 17, 2022
f0c7dad
Poetry
Stevendeo Nov 17, 2022
f0223f2
Rebase artifacts
Stevendeo Nov 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/sphinx_docs/Input_file_formats/Native/00_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ Reserved keywords are the following.

The list of all reserved keywords, in alphabetical order, is:
```
ac, and, axiom, bitv, bool, case_split, check, cut, distinct, else, end, exists, extends,
false, forall, function, goal, if, in, int, let, logic, not, xor, predicate, prop,
real, rewriting, then, theory, true, type, unit, void, match, with, of
ac, and, axiom, bitv, bool, case_split, check, check_sat, chevk_valid, cut,
distinct, else, end, exists, extends, false, forall, function, goal, if, in,
int, let, logic, not, xor, predicate, prop, real, rewriting, then, theory,
true, type, unit, void, match, with, of
```
Note that preludes (additional theories which may be loaded) may reserve more keywords.
43 changes: 42 additions & 1 deletion docs/sphinx_docs/Input_file_formats/Native/04_setting_goals.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,45 @@ In other word, `cut` and `check` allow to test if intermediate goals can be prov
<check_declaration> ::= 'check' <expr>
<cut_declaration> ::= 'cut' <expr>
```


## `check_valid`

This keyword is an alias for `goal`.

## `check_sat`

This keyword is used just like `goal` and `check_valid`, but it describes a property that alt-ergo will
try to prove invalid. This keywork has been introduced in the version 2.5.0 as a part of the model
instanciation, and in this version `alt-ergo` never returns `SAT`, but `unknown` instead.

### Example

test.ae
```
logic x, y : int

check_sat g: x = y
```

```
$ alt-ergo test.ae --model

unknown

(model

; Functions

; Constants

(define-fun x () int 0)

(define-fun y () int 0)

; Arrays not yet supported


)
File "test.ae", line 3, characters 14-19: I don't know (0.0030) (2 steps) (goal g)

```
18 changes: 18 additions & 0 deletions docs/sphinx_docs/Usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ Alt-Ergo supports file extensions:

See the [Input section] for more information about the format of the input files

### Generating models
Since 2.5.0, Alt-Ergo also generates models in the case it concludes on the satisfiability of
the formula.
There is two ways to activate model generation:

- with the `--model` option;

- `with the --interpretation=VALUE`, where VALUE can be equal to:
* "none", and alt-ergo will not generate models (by default);
* "first", and alt-ergo will output the first model it finds;
* "every", alt alt-ergo will compute a model before each decision
* "last", and alt-ergo will output the last model it computes before returning 'unknown'.
Note that this mode only works with the option `--sat-solver tableaux`.

NB: the `--model` option is equivalent to `--interpretation every --sat-solver tableaux`.

The default model format is the SMT format.

### Output
The results of an Alt-ergo's execution have the following form :
```
Expand Down
7 changes: 7 additions & 0 deletions examples/smt2/arith/arith1.ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
logic x : int
logic f : int -> int

(*axiom A1: forall x:int. f(x) < 100*)

check_sat g :
x <= 42 and x >= 0 and f(x) >= 42 and x + f(x) = 50
5 changes: 5 additions & 0 deletions examples/smt2/arith/arith1.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(set-logic ALL)
(declare-const x Int)
(assert (<= x 42))
(check-sat)
(get-model)
6 changes: 6 additions & 0 deletions examples/smt2/arith/arith2.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(set-logic ALL)
(declare-const x Int)
(declare-const y Int)
(assert (and (<= x 42) (>= x 0) (>= y 42) (= (+ x y) 50)))
(check-sat)
(get-model)
8 changes: 8 additions & 0 deletions examples/smt2/array/array1.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(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)
15 changes: 15 additions & 0 deletions examples/smt2/bool/bool1.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(set-logic QF_UF)
; (set-option :produce-models true) ; enable model generation
(declare-const p Bool)
(declare-const q Bool)
; (declare-const t Int)
(define-fun nq () Bool q)
(assert (=> (not p) (not nq)))
(check-sat)
(get-model)
(get-assignment)
(assert q)
(check-sat)
(get-model)
(get-assignment)
(exit)
10 changes: 10 additions & 0 deletions examples/smt2/bool/bool2.ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
logic x: bool
logic y: bool
goal ga1: x and y
goal ga2: x and not x
goal go1: x or y
goal go2: x or not x
check_sat ga1: x and y
check_sat ga2: x and not x
check_sat go1: x or y
check_sat go2: x or not x
7 changes: 7 additions & 0 deletions examples/smt2/bool/bool2.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(set-logic QF_UF)
(declare-const x Bool)
(declare-const y Bool)
(assert (or x (not x)))
(check-sat)
(get-model)
(get-assignment)
93 changes: 93 additions & 0 deletions examples/smt2/complete.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
(set-logic ALL)
(set-option :produce-models true)

;; Constants
;; Bools
(declare-const b Bool)
(assert b)
(check-sat)

;; Ints
(declare-const i Int)
(assert (> i 0))
(check-sat)

;; Reals
(declare-const r Real)
(assert (> r 0.0))
(check-sat)

;; UF
;; Bools
(declare-const fb_cst Bool)
(declare-const fb_cst2 Bool)
(declare-fun fb (Bool) Bool)
(declare-fun fb_b (Bool Bool) Bool)
(assert (and (fb fb_cst) (fb_b fb_cst fb_cst2)))
(check-sat)

;; Ints
(declare-const fi_cst Int)
(declare-fun fi (Int) Bool)
(declare-fun fii (Int) Int)
(declare-fun fii_i (Int Int) Int)
(assert (and (fi fi_cst) (= (fii fi_cst) 0) (= (fii_i 1 2) fi_cst)))
(check-sat)

;; Reals
(declare-const fr_cst Real)
(declare-fun fr (Real) Bool)
(declare-fun frr (Real) Real)
(declare-fun frr_r (Real Real) Real)
(assert (and (fr fr_cst) (= (frr fr_cst) 1.0) (= (frr_r 1.0 2.0) fr_cst)))
(check-sat)

;; Sorts
(declare-sort S0 0)
(declare-const sa S0)
(declare-const sb S0)
(assert (= sa sb))
(check-sat)

(declare-sort S1 1)
(declare-const s1a (S1 S0))
(declare-const s1b (S1 S0))
(assert (= s1a s1b))
(check-sat)

;; Arrays
(declare-const a (Array Int Int))
(assert (= a (store a 1 1)))
(assert (= (select a 1) 1))

(declare-const ai_cst Int)
(define-fun ai () (Array Int Int) (store a ai_cst 1))
(assert (= (select ai ai_cst) 1))
(check-sat)
(get-model)

;; Sums
(declare-datatype s ((A) (B) (C)))
(declare-const s_cst s)
(assert (or (= s_cst A) (= s_cst B)))
(check-sat)
(get-model)

;; Records
(declare-datatype r ((mk_r (r0 Int) (r1 Int))))
(declare-const r_cst r)
(assert (> (r0 r_cst) 1))
(check-sat)

(define-fun r_fun () r (mk_r 1 2))
(assert (= (r1 r_fun) 2))
(check-sat)
(get-model)

;; Adts
(declare-datatype IntList ((Cons (hd Int) (tl IntList)) (Nil)))
(declare-const l_cst IntList)
; not yet supported
;(assert (= (hd l_cst) 1))
;(assert (= l_cst Nil))
(check-sat)
Loading