Skip to content

Commit 82d0fbd

Browse files
committed
More
1 parent af71d8d commit 82d0fbd

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ethos 0.1.2 prerelease
1313
- The option `--print-let` has been renamed to `--print-dag` and is now enabled by default. The printer is changed to use `eo::define` instead of `let`.
1414
- Ethos now explicitly forbids `:var`, `:implicit`, and `:opaque` on return types.
1515
- The operator `eo::typeof` now fails to evaluate if the type of the given term is not ground.
16+
- Changes the semantics of `declare-parameterized-const`. In particular, the parameters of a parameterized constants are no longer assumed to be implicit, and are explicit by default. The `:implicit` attribute can be used on all parameters to recover the previous behavior.
17+
- Remove support for the explicit parameter annotation `eo::_`, which was used to provide annotations for implicit arguments to parameterized constants.
1618

1719
ethos 0.1.1
1820
===========

user_manual.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ The Eunoia language contains further commands for declaring symbols that are not
135135

136136
- `(define <symbol> (<typed-param>*) <term> <attr>*)`, defines `<symbol>` to be a lambda term whose arguments and body are given by the command, or just an arbitrary term defined by the provided the body, if the argument list is empty (i.e., it may be a non-function term). Note that in contrast to the SMT-LIB command `define-fun`, a return type is not provided. It is also possible to provide attributes to the definition: e.g. `:type`, which instructs the checker to perform type checking on the given term (see [type checking define](#tcdefine)).
137137

138-
- `(declare-parameterized-const <symbol> (<typed-param>*) <type> <attr>*)` declares a globally scoped variable named `<symbol>` whose type is `<type>`.
138+
- `(declare-parameterized-const <symbol> (<typed-param>*) <type> <attr>*)` declares a globally scoped variable named `<symbol>` whose expected arguments are given by the argument list, and whose return type is `<type>`.
139139

140140
> __Note:__ Variables are internally treated the same as constants by Ethos. However, they are provided as a separate category, e.g., for user signatures that wish to distinguish universally quantified variables from free constants. They also have a relationship with user-defined binders, see [binders](#binders), and can be accessed via the builtin operator `eo::var` (see [computation](#computation)).
141141
@@ -1019,7 +1019,7 @@ we declare bitvector-or (`bvor` in SMT-LIB) where its nil terminator is bitvecto
10191019
(BitVec (eo::len eo::self))) ; binary literals denote BitVec constants of their length
10201020
(define bvzero ((m Int)) (eo::to_bin m 0)) ; returns the bitvector value zero for bitwidth m
10211021
1022-
(declare-parameterized-const bvor ((m Int)) ; bvor is parameterized by a bitwidth m
1022+
(declare-parameterized-const bvor ((m Int :implicit)) ; bvor is parameterized by a bitwidth m
10231023
(-> (BitVec m) (BitVec m) (BitVec m))
10241024
:right-assoc-nil (bvzero m) ; its nil terminator depends on m
10251025
)
@@ -1030,8 +1030,9 @@ Then, we declare `bvor` using `declare-parameterized-const` where its parameter
10301030
The provided parameters are in scope for the remainder of the command, which means they can appear in the nil terminator of the operator.
10311031
Here, we specify `(bvzero m)` as the nil terminator for `bvor`.
10321032

1033-
The parameter list of a parameterized constant are treated as _implicit_ arguments.
1034-
In this example, the type of `bvor` is `(-> (! Int :var m :implicit) (BitVec m) (BitVec m) (BitVec m))`.
1033+
The parameter list of a parameterized constant may either be implicit or explicit arguments.
1034+
In this example, the argument `m` to `bvor` is implicit.
1035+
Thus, it expects two bit-vectors of the same width and returns a bit-vector of that width.
10351036

10361037
If a function `f` is given a nil terminator with free parameters, this impacts:
10371038

@@ -1096,12 +1097,6 @@ The term in the body of `test` desugars to `(bvor z (bvor w (eo::nil bvor z w)))
10961097
In this example, we instantiate this definition in the body of `test4`, where `n=4`, `z=a` and `w=b`.
10971098
The term `(bvor a (bvor b (eo::nil bvor a b)))` then evaluates to `(bvor a (bvor b #b0000)`, since the nil terminator of `(bvor a b)` has ground parameter `n=4` and evaluates to `#b0000`.
10981099

1099-
> __Note:__ Alternatively, the parameters of a function `f` may be provided explicitly using the syntax `(eo::_ f p1 ... pn)`.
1100-
When parameters are provided, these are used instead of the type inference method above.
1101-
Furthermore, these parameters are dropped when applying the operator to arguments.
1102-
For example `(_ (eo::_ bvor 4) a b)` is equivalent to `(bvor a (bvor b #b0000))` after desugaring.
1103-
An example use case for this feature is directly refer to the nil terminator of a concrete instance of `bvor`, e.g. `(eo::nil (eo::_ bvor 4))` evaluates to `#b0000`.
1104-
11051100
The following are examples of list operations when using parameterized constant `bvor`:
11061101

11071102
```smt
@@ -1112,7 +1107,6 @@ The following are examples of list operations when using parameterized constant
11121107
(eo::nil bvor) == (eo::nil bvor) ; since we cannot infer the type of bvor
11131108
(eo::nil bvor a) == #b0000 ; since #b0000 is the nil terminator of (bvor a)
11141109
(eo::nil bvor a c) == (eo::nil bvor a c) ; since (bvor a c) is ill-typed
1115-
(eo::nil (eo::_ bvor 4)) == #b0000
11161110
11171111
(eo::cons bvor a #b0000) == (bvor a)
11181112
(eo::cons bvor c #b0000) == (eo::cons bvor c #b0000) ; since (bvor c #b0000) is ill-typed
@@ -1122,7 +1116,7 @@ The following are examples of list operations when using parameterized constant
11221116
(eo::list_concat bvor (bvor a b) (bvor b)) == (bvor a b b)
11231117
```
11241118

1125-
> __Note:__ If no free parameters are used in the nil terminator of a parameterized constant, then it is treated equivalent to if it were declared via an ordinary declare-const command, and a warning is issued.
1119+
> __Note:__ If no free parameters are used in the nil terminator of a parameterized constant, then no special handling of the nil element of that function is necessary. In particular, this means that all applications of the `eo::nil` are eagerly replaced by the (ground) nil terminator.
11261120
11271121
<a name="overloading"></a>
11281122

0 commit comments

Comments
 (0)