Skip to content

Commit

Permalink
doc: Add examples for ae.float primitives (#1239) (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
bclement-ocp authored Sep 20, 2024
1 parent 1b9c826 commit af8193e
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions docs/sphinx_docs/SMT-LIB_language/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ the FloatingPoint SMT-LIB theory.
((_ ae.round prec exp) RoundingMode Real Real)
```

*Note*: While Alt-Ergo has built-in support for **computing** with `ae.round`
on known arguments, reasoning capabilities involving `ae.round` on non-constant
arguments are disabled by default and currently requires to use the flag
`--enable-theories fpa`.

`prec` defines the number of bits in the significand, including the hidden bit,
and is equivalent to the `sb` parameter of the `(_ FloatingPoint eb sb)` sort
in the FloatingPoint SMT-LIB theory.
Expand All @@ -70,7 +65,7 @@ of the `(_ FloatingPoint eb sb)` sort as `exp = 2^(eb - 1) + sb - 3`.

The result of `(_ ae.round prec exp)` is always of the form `(-1)^s * c * 2^q`
where `s` is a sign (`0` or `1`), `c` is an integer with at most `prec - 1`
binary digits (i.e. `0 <= c < 2^(prec - 1)`) and `q >= exp` is an integer.
binary digits (i.e. `0 <= c < 2^(prec - 1)`) and `q >= -exp` is an integer.

The following function symbols are provided as short synonyms for common
floating point representations:
Expand All @@ -79,3 +74,28 @@ floating point representations:
- `ae.float32` is a synonym for `(_ ae.round 24 149)`
- `ae.float64` is a synonym for `(_ ae.round 53 1074)`
- `ae.float128` is a synonym for `(_ ae.round 113 16494)`

### Examples

Input:

```smt-lib
(set-option :produce-models true)
(set-logic ALL)
(declare-const |0.3f32| Real)
(assert (= (ae.float32 RNE 0.3) |0.3f32|))
(declare-const |0.3f16| Real)
(assert (= (ae.float16 RNE 0.3) |0.3f16|))
(check-sat)
(get-model)
```

Output:

```smt-lib
unknown
(
(define-fun |0.3f32| () Real (/ 5033165 16777216))
(define-fun |0.3f16| () Real (/ 1229 4096))
)
```

0 comments on commit af8193e

Please sign in to comment.