You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,8 @@ ethos 0.1.2 prerelease
13
13
- 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`.
14
14
- Ethos now explicitly forbids `:var`, `:implicit`, and `:opaque` on return types.
15
15
- 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.
Copy file name to clipboardExpand all lines: user_manual.md
+6-12Lines changed: 6 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,7 +135,7 @@ The Eunoia language contains further commands for declaring symbols that are not
135
135
136
136
-`(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)).
137
137
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>`.
139
139
140
140
> __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)).
141
141
@@ -1019,7 +1019,7 @@ we declare bitvector-or (`bvor` in SMT-LIB) where its nil terminator is bitvecto
1019
1019
(BitVec (eo::len eo::self))) ; binary literals denote BitVec constants of their length
1020
1020
(define bvzero ((m Int)) (eo::to_bin m 0)) ; returns the bitvector value zero for bitwidth m
1021
1021
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
1023
1023
(-> (BitVec m) (BitVec m) (BitVec m))
1024
1024
:right-assoc-nil (bvzero m) ; its nil terminator depends on m
1025
1025
)
@@ -1030,8 +1030,9 @@ Then, we declare `bvor` using `declare-parameterized-const` where its parameter
1030
1030
The provided parameters are in scope for the remainder of the command, which means they can appear in the nil terminator of the operator.
1031
1031
Here, we specify `(bvzero m)` as the nil terminator for `bvor`.
1032
1032
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.
1035
1036
1036
1037
If a function `f` is given a nil terminator with free parameters, this impacts:
1037
1038
@@ -1096,12 +1097,6 @@ The term in the body of `test` desugars to `(bvor z (bvor w (eo::nil bvor z w)))
1096
1097
In this example, we instantiate this definition in the body of `test4`, where `n=4`, `z=a` and `w=b`.
1097
1098
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`.
1098
1099
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
-
1105
1100
The following are examples of list operations when using parameterized constant `bvor`:
1106
1101
1107
1102
```smt
@@ -1112,7 +1107,6 @@ The following are examples of list operations when using parameterized constant
1112
1107
(eo::nil bvor) == (eo::nil bvor) ; since we cannot infer the type of bvor
1113
1108
(eo::nil bvor a) == #b0000 ; since #b0000 is the nil terminator of (bvor a)
1114
1109
(eo::nil bvor a c) == (eo::nil bvor a c) ; since (bvor a c) is ill-typed
1115
-
(eo::nil (eo::_ bvor 4)) == #b0000
1116
1110
1117
1111
(eo::cons bvor a #b0000) == (bvor a)
1118
1112
(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
1122
1116
(eo::list_concat bvor (bvor a b) (bvor b)) == (bvor a b b)
1123
1117
```
1124
1118
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.
0 commit comments