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: user_manual.md
+40-7Lines changed: 40 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -201,7 +201,7 @@ Note the following declarations generate terms of the same type:
201
201
(declare-const Array_v3 (-> Type Type Type))
202
202
```
203
203
204
-
<aname="literals"></a>
204
+
<aname="tcdefine"></a>
205
205
206
206
### The :type attribute for definitions
207
207
@@ -240,12 +240,10 @@ In general, an argument can be made implicit if its value can be inferred from t
240
240
241
241
Return types cannot be marked `:implicit` or `:var` or a type error will be immediately reported.
242
242
243
-
We call `T` in the above definitions a _parameter_. The free parameters of the return type of an expression should be contained in at least one non-implicit argument. In particular, the following declaration is malformed, since the return type of `f` cannot be inferred from its arguments:
244
-
245
-
```smt
246
-
(declare-type Int ())
247
-
(declare-const f (-> (! Type :var T :implicit) Int T))
248
-
```
243
+
We call `T` in the above definitions a _parameter_.
244
+
Typically, the free parameters of the return type of a function should be contained in an explicit argument.
245
+
If not, the function is considered *ambiguous* and requires an annotation with the SMT-LIB syntax `as`.
246
+
For details, see [ambiguous functions](#amb-functions).
249
247
250
248
> __Note:__ Internally, `(! T :var t)` is syntax sugar for the type `(Quote t)` where `t` is a parameter of type `T` and `Quote` is a distinguished type of kind `(-> (! Type :var U) U Type)`. When type checking applications of functions of type `(-> (Quote t) S)`, the parameter `t` is bound to the argument the function is applied to.
251
249
@@ -574,6 +572,38 @@ Furthermore, note that a binder also may accept an explicit term as its first ar
574
572
In the above example, `Q4` has `(@cons x)` as its first argument, where `x` was explicitly defined as a variable.
575
573
This means that the definition of `Q4` is also syntactically equivalent to the definition of `Q1` and `Q2`.
576
574
575
+
<aname="amb-functions"></a>
576
+
577
+
### Ambiguous Functions
578
+
579
+
Functions and constants that are declared via the command `declare-parameterized-const` may have return types that contain free parameters.
580
+
If these parameters are *not* contained in any explicit argument to the function, then the function or constant is considered *ambiguous*.
581
+
For example, consider a generic definition of the empty set:
582
+
583
+
```smt
584
+
(declare-type Set (Type))
585
+
(declare-parameterized-const set.empty ((T Type :implicit)) (Set T))
586
+
587
+
(declare-type Int ())
588
+
(define f () (as set.empty (Set Int)) :type (Set Int))
589
+
```
590
+
591
+
Above, set is declared as a parameteric type.
592
+
The empty set has an implicit type argument `T` and has return type `(Set T)`.
593
+
Since `T` is a free parameter, and `set.empty` has no implicit arguments, it is an ambiguous function.
594
+
All uses of ambiguous functions must use the SMT-LIB syntax `as`,
595
+
which expects the symbol to annotate and the return type of that instance.
596
+
Above, `(as set.empty (Set Int))` refers to the instance of `set.empty` that has type `(Set Int)`.
597
+
598
+
The type of all ambiguous functions is automatically extended with an opaque type argument.
599
+
600
+
> __Note:__ Internally, type of all ambiguous functions is automatically extended with an opaque type argument.
601
+
In the above example, `set.empty` is internally defined to be of type `(-> (Quote (Set T)) (Set T))`.
602
+
Ethos interprets `(as set.empty (Set Int))` as `(_ set.empty (Set Int))`, where this is an "opaque" application (see [opaque](#opaque)).
603
+
Conceptually, this means that `(_ set.empty (Set Int))` is a constant symbol (with no children) that is indexed by its type.
604
+
605
+
A similar treatment is given to ambiguous datatype constructors, which we describe later in [parameteric datatypes](#par-datatypes).
606
+
577
607
<aname="literals"></a>
578
608
579
609
### Literal types
@@ -1230,6 +1260,9 @@ Applying the proof rule `dt-split` to a variable `x` of type `Tree` allows us to
1230
1260
Note that the definitino of `dt-split` is applicable to *any* datatype definition.
1231
1261
In particular, as a second example, we see the rule applied to a term `y` of type `Color` gives us a conclusion with three disjuncts.
1232
1262
1263
+
1264
+
<aname="par-datatypes"></a>
1265
+
1233
1266
### Parametric datatypes
1234
1267
1235
1268
Ethos supports reasoning about parametric datatypes with ambiguous datatype construtors using the same syntax as SMT-LIB 2.6.
0 commit comments