Skip to content

Commit 9f52857

Browse files
more cleanup
1 parent af17cc4 commit 9f52857

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

docs/Manual.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ ex21 = constrained $ \ d -> width_ d ==. lit 1
10291029

10301030

10311031
## Naming introduced lambda bound Term variables
1032-
1. [var|name|]
1032+
1. `[var|name|]`
10331033

10341034
When we use a library function that introduces new Term variable using a Haskell lambda expression, the system
10351035
gives the Haskell variable a unique Term level name such as `v0` or `v1` or `v2` etc. When the specification is
@@ -1088,16 +1088,12 @@ Original spec ErrorSpec
10881088

10891089

10901090
## Existential quantifiers
1091-
1. `exists`
1092-
2. `unsafeExists`
1091+
1. `exists`
1092+
2. `unsafeExists`
10931093

1094-
1095-
Sometimes we want to constrain a variable, in terms of another internal or hidden variable.
1096-
A classic example is constraining a number to be odd. A number `x` is odd, if there exists
1097-
another internal number `y`, such that, `x` is equal to `y + y + 1`
1098-
1099-
1100-
Here is an example.
1094+
Sometimes we want to constrain a variable, in terms of another internal or
1095+
hidden variable. A classic example is constraining a number to be odd. A
1096+
number `x` is odd, if there exists a number `y` such that `x == y + y + 1`:
11011097

11021098
```haskell
11031099
ex22 :: Specification Int
@@ -1106,18 +1102,18 @@ ex22 = constrained $ \ [var|oddx|] ->
11061102
(\ [var|y|] -> [Assert $ oddx ==. y + y + 1])
11071103
```
11081104

1109-
Why do we call the library function `unsafeExists`? It is unsafe because the library function
1110-
`conformsToSpec` will fail to return `True` when called on a generated result. Why?
1111-
Because the system does not know how to find the internal, hidden variable. To solve this
1112-
the safe function `exists` takes two Haskell lambda expressions. The first is a function
1113-
that tells how to compute the hidden variable from the values returned by solving the constraints.
1114-
The second is the normal use of a Haskell lambda expression to introduce a Term variable
1115-
naming the hidden variable. Here is an example.
1105+
Why do we call the library function `unsafeExists`? It is unsafe because the
1106+
library function `conformsToSpec` will fail to return `True` when called on a
1107+
generated result. Why? Because the system does not know how to find the
1108+
hidden variable `y`. To solve this the safe function `exists` takes two
1109+
Haskell lambda expressions. The first is a function that tells how to compute
1110+
the hidden variable from the values returned by solving the constraints. The
1111+
second is the normal use of a Haskell lambda expression to introduce a Term
1112+
variable naming the hidden variable:
11161113

11171114
```haskell
11181115
ex23 :: Specification Int
1119-
ex23 = ExplainSpec ["odd via (y+y+1)"] $
1120-
constrained $ \ [var|oddx|] ->
1116+
ex23 = constrained $ \ [var|oddx|] ->
11211117
exists
11221118
-- first lambda, how to compute the hidden value for 'y'
11231119
(\eval -> pure (div (eval oddx - 1) 2))
@@ -1126,19 +1122,21 @@ ex23 = ExplainSpec ["odd via (y+y+1)"] $
11261122
(\ [var|y|] -> [Assert $ oddx ==. y + y + 1])
11271123
```
11281124

1129-
One might ask what is the role of the parameter `eval` in the first lambda expression passed to `exists`.
1130-
Recall that we are trying assist the function `conformsToSpec` in determining if a completely known value
1131-
conforms to the specification. In this context, every Term variable is known. But in the specification we
1132-
only have variables with type `(Term a)`, what we need are variables with type `a`. The `eval` functional parameter
1133-
has type
1125+
One might ask what is the role of the parameter `eval` in the first lambda
1126+
expression passed to `exists`. Recall that we are trying assist the function
1127+
`conformsToSpec` in determining if a _completely known_ value conforms to the
1128+
specification. In this context, every Term variable bound before this point is
1129+
known. But in the specification we only have variables with type `(Term a)`,
1130+
what we need are variables with type `a`. The `eval` functional parameter has
1131+
type:
11341132

1135-
```haskell
1133+
```
11361134
eval :: Term a -> a
11371135
```
11381136

1139-
This, lets us access those values. In the example the Term variable `(oddx :: Term Int)` is in scope, so
1137+
This lets us access those values. In the example the Term variable `(oddx :: Term Int)` is in scope, so
11401138
`(eval oddx :: Int)`, and since this is only used when calling `conformsToSpec`, we actually have the
1141-
value of the `oddx` for `eval` to return. Finally `(div (eval oddx - 1) 2))` tells us how to compute
1139+
value of the `oddx` for `eval` to return. Finally `div (eval oddx - 1) 2` tells us how to compute
11421140
the value of the hidden variable.
11431141

11441142

0 commit comments

Comments
 (0)