lawspec 0.15.2 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### GADTs
6
+
7
+ A constructor can fix a type parameter: `| Number value :: BigInt where a =
8
+ BigInt` builds only `Expr BigInt`. Matching refines the parameter in each
9
+ branch, so `definition eval (e :: Expr a) :: a` type-checks. A constructor that
10
+ cannot build a type is no value of it: matches need no branch for it, and
11
+ decoding rejects it. Definitions may call themselves at other instances
12
+ (polymorphic recursion), up to 64 instances each. Existentials determined by
13
+ the type (`where a = Pair b c`) are supported, and so are existentials only a
14
+ field mentions: each such value carries its type as a trailing `witness` field,
15
+ and generated values draw it from `Bool` and `Int32`. Native types use each
16
+ target's own GADT form where it has one: sealed interfaces of records in Java,
17
+ Kotlin data classes, Haskell GADT syntax, TypeScript conditional unions and
18
+ `Expr[int]` in Python. See [GADTs](docs/reference/language/gadts.md).
19
+
20
+ ### Index arithmetic and shared indices
21
+
22
+ - Index expressions accept `+ - * div mod ^`. Subtraction never truncates:
23
+ `n = m - 1` requires `m >= 1`, as a runtime-checked constructor constraint.
24
+ - A variable bound by several fields makes their indices equal, so
25
+ `Node left :: Perfect m right :: Perfect m` declares perfect trees.
26
+ - An implicit index may first appear as `v + k` or `k * v`:
27
+ `dropFirst :: (xs :: Row (k + 1)) -> (r :: Rest k)`.
28
+ - Products and powers are uninterpreted atoms in the prover, so `r * c` and
29
+ `c * r` agree. A definition's non-linear result index that cannot be proved
30
+ is checked on each result and reported as `runtime-checked`; a linear one is
31
+ still an error.
32
+ - Generation solves any equation backwards over the indices each constructor
33
+ can reach, in all seven runtimes. This fixes `n = m + m`, which used to build
34
+ children of the wrong size, and builds balanced trees even without a fixed
35
+ index.
36
+
37
+ See [indexed families](docs/reference/language/indexed-families.md).
38
+
39
+ ### Flow types
40
+
41
+ `pop :: Stack (n + 1) / Stack n -> Int8` declares a flow parameter: the call
42
+ takes the stack from one type to another. In laws, `~s` passes a state and
43
+ rebinds it to the state the call leaves, and `e1; e2` sequences:
44
+ `(push x ~s; pop ~s) = x`. Each clause is checked left to right, so a pop the
45
+ stack cannot take is a compile error that suggests a bound. A definition
46
+ updates its flow parameter with `~s := e`. Each flow function returns a
47
+ generated product (`PopFlow` with `result` and `state`), indexed by the state
48
+ it leaves, so adapters' output states are runtime checked. See
49
+ [flow types](docs/reference/language/flow-types.md).
50
+
51
+ ### Other changes
52
+
53
+ - A type variable that only a field mentions is now an existential, not an
54
+ error.
55
+ - Rust property tests run on a thread with a 64 MiB stack, for deep generated
56
+ values.
57
+ - New acceptance suites `gadt` and `flow`, and `indexed` gains
58
+ `examples/specs/indexed_arithmetic.lawspec`, with mutants for every target.
59
+ - The [roadmap](docs/explanation/roadmap.md) records 0.12 to 0.19.
60
+
3
61
  ## 0.15.2
4
62
 
5
63
  Generated data types are the types you would write by hand, so adapters no
package/README.md CHANGED
@@ -30,7 +30,7 @@ Node 22+ and the selected target's build tools are required. No Haskell
30
30
  toolchain is needed. The reference platforms are macOS and Linux.
31
31
 
32
32
  ```sh
33
- npm install --save-dev lawspec@0.15.2
33
+ npm install --save-dev lawspec@0.16.0
34
34
  npx lawspec --version
35
35
  ```
36
36
 
@@ -40,8 +40,8 @@ LawSpec can create `package.json` and its test script:
40
40
  ```sh
41
41
  mkdir lawspec-example
42
42
  cd lawspec-example
43
- npm exec --package=lawspec@0.15.2 -- lawspec init --target javascript
44
- npm install --save-dev lawspec@0.15.2
43
+ npm exec --package=lawspec@0.16.0 -- lawspec init --target javascript
44
+ npm install --save-dev lawspec@0.16.0
45
45
  npx lawspec check
46
46
  npx lawspec explain 'example.atoi_codec::itoa and then atoi yields a'
47
47
  npx lawspec doctor
package/bin/lawspec.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  atomicWrite,
15
15
  safePath,
16
16
  } from "../files.mjs";
17
- const VERSION = "0.15.2";
17
+ const VERSION = "0.16.0";
18
18
  const args = process.argv.slice(2);
19
19
  const verb = args.shift();
20
20
  const options = {};
package/build.json CHANGED
@@ -64,6 +64,7 @@
64
64
  "src/LawSpec/Elaboration.hs",
65
65
  "src/LawSpec/Emit.hs",
66
66
  "src/LawSpec/Eval.hs",
67
+ "src/LawSpec/Flow.hs",
67
68
  "src/LawSpec/Frontend.hs",
68
69
  "src/LawSpec/GoData.hs",
69
70
  "src/LawSpec/GoDefinitions.hs",
@@ -80,6 +81,7 @@
80
81
  "src/LawSpec/HaskellTestHelpers.hs",
81
82
  "src/LawSpec/HaskellTypeRefs.hs",
82
83
  "src/LawSpec/Imports.hs",
84
+ "src/LawSpec/IndexTerm.hs",
83
85
  "src/LawSpec/Indexed.hs",
84
86
  "src/LawSpec/Inference.hs",
85
87
  "src/LawSpec/JavaData.hs",
@@ -125,6 +127,7 @@
125
127
  "src/LawSpec/WebExpr.hs",
126
128
  "src/LawSpec/WebNativeBinding.hs",
127
129
  "src/LawSpec/WebTypes.hs",
130
+ "src/LawSpec/Witness.hs",
128
131
  "stack.yaml",
129
132
  "stack.yaml.lock",
130
133
  "wasm/app/Exports.hs",
@@ -134,136 +137,139 @@
134
137
  ],
135
138
  "digests": {
136
139
  "dev/Gen/Embed.hs": "fd79909790f2026ff40a6de58897a934141e5eba1ca31b2d8cd3b128335def55",
137
- "lawspec.cabal": "71c35135612a099efed85364a358f80afdf15bf938f333b093e706dc23d6741b",
138
- "package.yaml": "2ad33d204efa6edcdf25c309c63e63531e5f3e33c53b04a12837cf1111cd1474",
139
- "runtime/LawSpecCodecs.hs": "90cb1ed15d7ab664a17a054580c849408d77cfd2b2adcb4a3228b05132caeaca",
140
- "runtime/LawSpecDataStrategies.hs": "cbe9f1946228db1076c19cd3158e8798fe32766cfdbea3f66b63d22d3d217508",
141
- "runtime/LawSpecDataStrategies.java": "e3416efe8a0d7b1276cb4d1a8105fd01b1f5f3f02a803bf55d955d9e3ec39095",
140
+ "lawspec.cabal": "863195f7e8a622ce221cc77950dd222cda9898aa933992bb9d45f397805865d4",
141
+ "package.yaml": "6f2af0809e56b2270547f82347676c4c2a332e68f61393214244b24fbf9a5288",
142
+ "runtime/LawSpecCodecs.hs": "1b3f6b40ad49928cf5e9386e06bc2992c9f1271754351b9fa3075e50346ef03b",
143
+ "runtime/LawSpecDataStrategies.hs": "3b0cb7733415f114e169a3bbca2e9966592c88e53890a83c1a73de95586f08a1",
144
+ "runtime/LawSpecDataStrategies.java": "63877c7b41002c6cff78ba42f33ca73cc2f79f938b3520bd50529c7e4d05f107",
142
145
  "runtime/LawSpecKotlin.kt": "0cf3b7de0406155225ccca33ee3dfdf8f0456c47d577f6be8f1265c13df838cb",
143
146
  "runtime/LawSpecKotlinCodecs.kt": "6210f77dbbe24ba2088db48dae5415abf0993fe552fb3a57d29430807efbc297",
144
- "runtime/LawSpecKotlinStrategies.kt": "c07ef4da5ccdab9045f50f08dbfcc4a7349a505af76bd5d3ddc8c00e879437f3",
145
- "runtime/LawSpecRuntime.hs": "5ced6a6a86a892ae63a544d4c4a4429bf756a730ea786478d820c8070cc96402",
146
- "runtime/LawSpecRuntime.java": "c7b7cfc9b7c22b082edee14a52d95ef80ebe01ee56988c22702f629ea24b8a4f",
147
- "runtime/LawSpecSchema.hs": "9912d9f525426a598f9c03c29cfc7bacf80218f73c9d537d8c1257bae245aa33",
148
- "runtime/LawSpecSchema.java": "885f5f17a9ea1bdb86915dc184aea25b72c3062d6ddb9605530310540b1cc166",
147
+ "runtime/LawSpecKotlinStrategies.kt": "a33c636d2377827501794b10c5debe6c6e0e5c8edf5db51dcb4760d6afd2efe5",
148
+ "runtime/LawSpecRuntime.hs": "2bc1be214ae77a47a3e873c44c3fa0774e2c38cf7072f16d8e769ea2442cff04",
149
+ "runtime/LawSpecRuntime.java": "d6a098e85bdd33fb12d1e31bfce6be3ebfe4fe1baa244cb55aa875376f05f54a",
150
+ "runtime/LawSpecSchema.hs": "2f6183caa02e511d7138e298a267b0273740e1ea4643cbec7f2bfc94aad61021",
151
+ "runtime/LawSpecSchema.java": "3f7e7008ad3a6f57513cac4a69b49903e216abb5f4842af65f9bd96bff1a8d86",
149
152
  "runtime/LawSpecStrategies.kt": "569f7775c0ac44765d05567cbf62d026558ac193c080ca71681ec6ee49c21794",
150
153
  "runtime/lawspec_codecs.go": "b3024fe60b3b66df9ebffe995ab5bb0294a609a82c611d54957e092eac29f2f5",
151
- "runtime/lawspec_data_strategies.go": "ec151dbdd1af89f57ce11c10d057d4bbc44691b0472035e0756ced1e0769a640",
152
- "runtime/lawspec_data_strategies.mjs": "e74a508bf2cd382ad1ca6bc90b6be19b10170e6261dbb902f58522fa2880c2fc",
153
- "runtime/lawspec_data_strategies.py": "3469bab1af47b5fb9583569d0a07f3c2a0485303d79347afe509cf34b6a21296",
154
- "runtime/lawspec_runtime.go": "af6ef660387b625b3bb5fcd57f06260c821d4f65eda158db44ad12d66e1d70f8",
155
- "runtime/lawspec_runtime.mjs": "3b7877c1ee523afba30ed24cd452e2a6126d9e741c7675600e867600d7a73f46",
156
- "runtime/lawspec_runtime.py": "2f780bc92762eb1115f734a36cc224ae34504929b4ff0ec506735cfa9e3ab02b",
157
- "runtime/lawspec_runtime.rs": "7ae8afaad638a3d9d6973eebc7cd6daecc8012ec57f3f12ff50cca16e23e15b6",
158
- "runtime/lawspec_schema.go": "bdfb6f2552bfccf56073d52f7cdbe1d784cba2d956c29762d77df7ad6bba8d67",
159
- "runtime/lawspec_schema.mjs": "60eb4204461eaa2c207fc7c3394014e2a814e4383b7045c065b4dae7c7a202c2",
160
- "runtime/lawspec_schema.py": "b6967ef1a33fe6a1a180d5573ec37cd8bb2079c06e961ac2eeb05f23cffcdd07",
161
- "runtime/lawspec_strategies.rs": "cac9ca301d4614fff9acfe61e7cc5678fabc044edadfa89ec11599b6780dc5f3",
162
- "runtime/rust/Cargo.lock": "de9883276068ebde2f10ed64f23a97d416a403c61d5b2709d246019dd94d72cb",
163
- "runtime/rust/Cargo.toml": "46f69975bd3771c6f5db6a1e7e08a8bb652d7f7662947bbac450d6bfff452d45",
154
+ "runtime/lawspec_data_strategies.go": "765da0ccfd19fa861abf800f9d831477a623e7685d34c4aad0f502b04877cea9",
155
+ "runtime/lawspec_data_strategies.mjs": "b7cc514593724b860bf6bc26841b3bf8347ec37447b93f9c7c325e2764ae5fb2",
156
+ "runtime/lawspec_data_strategies.py": "1e298e5e578a383c27af5674595efe1e4e037eb1685fc5f37df897e35aeba938",
157
+ "runtime/lawspec_runtime.go": "964195fb153980185bb99f30c13c474b432dec59249e1757f5912a20b3b39204",
158
+ "runtime/lawspec_runtime.mjs": "180879c7573dd7f95e897f30de6120d822efe0237815f0d3553864668df21fdb",
159
+ "runtime/lawspec_runtime.py": "a27f0c3c66495c045190f65ae0fa2e9ff8ab8f539c1b30ce6b4b55a17f727589",
160
+ "runtime/lawspec_runtime.rs": "6f3341727b31930445dd0467fe08caea83129886fbbc589496f09cbbd6838c8b",
161
+ "runtime/lawspec_schema.go": "db52428bf4e72a26c11f199f98bafa8d5dddd8a7a8d5c4f02d6e57c3b0938ea5",
162
+ "runtime/lawspec_schema.mjs": "2a4847b35b1d460e1847b1328e58b364ee9ec90de35ec34dc4ceb55bfed4d00d",
163
+ "runtime/lawspec_schema.py": "89895cc148389c7a7eee3eff9e28434ba413ac3e30cb151a65beca64e5316b41",
164
+ "runtime/lawspec_strategies.rs": "f099694d155df69e9d2af471973829b74c12cc4d0c95c98940fcad0b182e59ed",
165
+ "runtime/rust/Cargo.lock": "b7c772f721bf5a4345a6ab92909881bae4a2ecd087c1e6e83bbbc101dc5de5ae",
166
+ "runtime/rust/Cargo.toml": "5b84ef77431998b7c016107f7ea6e19c466f05254b3b46874a8e61e8c4fdf814",
164
167
  "src/LawSpec/Api.hs": "b7315b30890e3e38382c7e4d60afdfc6c7c3647f056636c230a91c16047f9944",
165
168
  "src/LawSpec/Backend.hs": "03c3b0cd62467ca677c88d29d7b12b2ab505cc0076d93d1f48fbddb0e9bcf133",
166
169
  "src/LawSpec/Capabilities.hs": "e43d4fc3a4481fbb8aa3ff1c3f41f7e7fca5db01bfe256a30162a45d75a00c1c",
167
170
  "src/LawSpec/Code/Doc.hs": "9e3b70f85deb1dcbce385af1d0cd4bea2dfa8a2d806d54745d4bb437406673e5",
168
171
  "src/LawSpec/Code/JavaScript.hs": "77bf27dcc210216e4739f68c4709f556f80130ab83b3b9387ac4a2421e790910",
169
172
  "src/LawSpec/Common.hs": "107612a8aaa787488413acf9c1a56622004d3bff251db89b99928343e6070883",
170
- "src/LawSpec/Compile.hs": "ac7c9d81b7c205b1d56a30f94bd8474c6910db8ecab4802f451ab39a10fe073b",
171
- "src/LawSpec/Core.hs": "ec081c49e5ccce95f84ded6073f1d8f30298f061dd8b94437d4b00410c57f27c",
173
+ "src/LawSpec/Compile.hs": "73bffc942d3a80fb6f9b13b25f18f7ebc797bc784176deb6c59bbc660a6dc1b1",
174
+ "src/LawSpec/Core.hs": "5a35c9d90c563bcc81fdb14202a89fbf049d553e2faaddef78a767370b7d7f7d",
172
175
  "src/LawSpec/Core/DefinitionContracts.hs": "b7f60f038b231187ecf898e585ae1a8fb1fc113bb55bad6d1bb2660350fd969e",
173
- "src/LawSpec/Core/Definitions.hs": "52f024fca59661142f70f9aa7dd2cbdb4892e5d3b1ca8079c878c5a1ba667112",
176
+ "src/LawSpec/Core/Definitions.hs": "8e0d1d7127f9d4872f2464b4af50b0f286823d5f0f203baf38fb3c316d766140",
174
177
  "src/LawSpec/Core/Eval.hs": "e1ad8af5b240dd99c3b1126408d2be5f9b42b86ca6189ecd3868680a5119d931",
175
- "src/LawSpec/Core/Evidence.hs": "84976ccfc84f8f31c8391008cd767b75753488f9e7872045ab0c997f6f1d8613",
176
- "src/LawSpec/Core/Expression.hs": "84985f4f685126253d3af7b6b605d80d28fc9aa115bd5e2946f989eeb1355224",
177
- "src/LawSpec/Core/Payload.hs": "df6a2b250c27c12bb6ac16b84847c52546081d066a3dca7575ed0d743cc13d50",
178
+ "src/LawSpec/Core/Evidence.hs": "509d244242850d1abbba1105836529f1d3546dd39129d6fcc8abd3087e385658",
179
+ "src/LawSpec/Core/Expression.hs": "0cbd2901e50537b2dad2ddf2ab28f9e317d6fb0778375055e66efe72d360168c",
180
+ "src/LawSpec/Core/Payload.hs": "da2417fc99354338eab49a688c5f36cecde5ec1aacd8582c895428568b10a376",
178
181
  "src/LawSpec/Core/PayloadPlan.hs": "f2a7d2dc58c6a0f79707bdc24773bd3aad3a3b8eea2735a8284b2a9f3a4af4a8",
179
182
  "src/LawSpec/Core/RefinementProof.hs": "c19fc03e68488357a59897ec38ce3d2efd320c35b405b632af17425d6a18447a",
180
- "src/LawSpec/Core/Schema.hs": "9a4ec3967803913e6ff43d33e00a1b4b3b8ec0c79dbdbd80ae98101c85bf430f",
181
- "src/LawSpec/Core/Semantics.hs": "a9d019433e3b9731f8cd0f65ec0ccc53179824bea58247b72df26760b878c2b6",
182
- "src/LawSpec/Core/Total.hs": "95d2b19ba7fbfd033295504d31f786815384003b3b4d370776860b423cf079dd",
183
- "src/LawSpec/Core/Totality.hs": "3bd81ebdd2020d8b17809904a42a2d5f0a12075d8b8b3fa3b1907bdc7024bd46",
184
- "src/LawSpec/Core/Types.hs": "48ed1d197ce7089737895b7279f93437301fcfacff8b3a8dd98ecd7f1cb32b37",
185
- "src/LawSpec/Core/Validate.hs": "0f045241215e068081d6cd7cf451f0166671bae5fffafda71a2e2320e8014c27",
186
- "src/LawSpec/Core/Value.hs": "f2b2e4d82491e184d60b1217922b25c57a06cbbaecb2cb6f31174af50268fbc9",
187
- "src/LawSpec/CoreEmit.hs": "075f06ef1be2437542967b171c535686f33ed4645f6525a93c1024a9fbf68582",
183
+ "src/LawSpec/Core/Schema.hs": "ce06bd96b63d11f80be518e626b33526668ae1e2f3f7fc626bb1048e296efc21",
184
+ "src/LawSpec/Core/Semantics.hs": "cdb8256e523f7808fa50fe7d80d709217a28de4c81c5ff5be8382f94900f3779",
185
+ "src/LawSpec/Core/Total.hs": "308684d7ff78a5e4dc75aef30c4df17610a2cb107d48ddb75d14d8573b178e5b",
186
+ "src/LawSpec/Core/Totality.hs": "5e76100466cf4a157b9eda36738806af836a5bda949f5d568d7bf5155fa8858a",
187
+ "src/LawSpec/Core/Types.hs": "b6c2dac8610ae314d84467323a449f352acbeaed9138de8fa6e129cd07ef9529",
188
+ "src/LawSpec/Core/Validate.hs": "74c2a51eb913f8414268064f22d2d5d97ebfb0e4797e146b229076c29ac38726",
189
+ "src/LawSpec/Core/Value.hs": "c5d2362b72c4b2944424da0f47409f8eeb918f0c01a48a603d06e73e99c63808",
190
+ "src/LawSpec/CoreEmit.hs": "633657bbd7131a17261e48b7ab108cb27c299fc685b04be7605814a1aa5af43d",
188
191
  "src/LawSpec/CoreNativeScalarEmit.hs": "4082661ba5f8b1b09b4811f62ba767fa1ea401a38dd10011aea442c5a27892af",
189
- "src/LawSpec/CoreScalarEmit.hs": "d1a51f7fe9b23817eeac7b50dac70ec02219df66d4b0218c5c9ae5237da244fd",
190
- "src/LawSpec/Data.hs": "9dbeafa120276b114dad790ec69e617f7ad0c632e3c718962f2f7faf8ca327f4",
192
+ "src/LawSpec/CoreScalarEmit.hs": "93db9eea5e3c0d27a73c15ff48a0a828a4980f1990d82c91015fe5f0067dcdbb",
193
+ "src/LawSpec/Data.hs": "f659f4e86f1009c4806334a45686970dde2efa2641585f997a7beba01d0e6f2d",
191
194
  "src/LawSpec/DataNames.hs": "2eeb0d215131981a2271725a50c21dce44c7146a167025eb239a83922fdecaf6",
192
- "src/LawSpec/DefinitionTotality.hs": "7671b7efb0cac5d796b074d48b2c10940e5bd0b5df082b926aee694903285efa",
193
- "src/LawSpec/Discharge.hs": "4b0a5692b31be7620239a4ac5175a0ef2950fc223f708b34895a7cde17a98e95",
195
+ "src/LawSpec/DefinitionTotality.hs": "9c0ecc8b0f2f29ffc701ee16ae3a6436e8be2711fb18669d7a587443c0497217",
196
+ "src/LawSpec/Discharge.hs": "bd1acbddecf1f060aaaad1a6796825321c56b434d556e9873eb6c9d99459fdb7",
194
197
  "src/LawSpec/Domain.hs": "222d15f0012ae630802238a6d7e1ee78d1e718b599f5ebb5a1ddc4e8d29d68c3",
195
- "src/LawSpec/DomainModel.hs": "3be67117c44e66a39d42d7ce094c2940c48ea1541017b64027afa6ea4b77092f",
196
- "src/LawSpec/Elaboration.hs": "86e3ef77a977cb1b55985e2939648135acd0c2c015afe76e34e09615d555f53e",
198
+ "src/LawSpec/DomainModel.hs": "835e6e31c9565bd624c1139ead71ad65c1065ee660457ae365522f7ed78f7939",
199
+ "src/LawSpec/Elaboration.hs": "3de34b3de3804e1733ff4d5fa9cbb51745c5cbc63b02626ab8b05f52672426e0",
197
200
  "src/LawSpec/Emit.hs": "9f34f5765915a2a12a66a6dca647ddaef9289372956802c6d99cf0cfec447c7a",
198
- "src/LawSpec/Eval.hs": "b0872ba8a6974463b32776653c2939826a6be87318c15641401f913f6b139de2",
199
- "src/LawSpec/Frontend.hs": "fbf091b9c96f5b5361dbf4f65819634c0f8526ff98550d97c434c0d47af7839e",
200
- "src/LawSpec/GoData.hs": "26cdefe056f6ce01469cb13d9edab8e1ace9c47391daa2fa050ee4e741ee7cc6",
201
- "src/LawSpec/GoDefinitions.hs": "3cb55c22f28443fff73e73c59780bf1977ab9260b8d66c7f19d1b94b40d1397e",
201
+ "src/LawSpec/Eval.hs": "b87a786ed7a512c60e00a037a1a36738933518aafa255babaa8b1b42dbb8ff6d",
202
+ "src/LawSpec/Flow.hs": "830b9d59b94f26a05687bd5baed06b4ecbf1f47c6a634766810d3dd2a44647cd",
203
+ "src/LawSpec/Frontend.hs": "5f2bb4f3580b8fca6d899a0b40000da653fb7e76f11f8c8df271eb023ad5b278",
204
+ "src/LawSpec/GoData.hs": "d146db8888f2ee03b5331daa7f12d4acc37949d8aa603f48a4ddbc72f36e52bb",
205
+ "src/LawSpec/GoDefinitions.hs": "fe689dc973ef79fd628b7cee08bf8ddd1800a4c10430b7d1ac75279138513684",
202
206
  "src/LawSpec/GoExpr.hs": "da3a7cc0e3d2906886dc44f6b990e72098bb351558bbb31ee335da7382fac58a",
203
207
  "src/LawSpec/GoNativeBinding.hs": "1ad8ea4cec6187c7e6005651c0edeec69e196eb329fb958c833da7751225aa1b",
204
- "src/LawSpec/GoProperties.hs": "1eee75d852b0a1f8b6fe2cfb1cd3ed7dc57f44ca0ee137697729e8e1583d85fe",
208
+ "src/LawSpec/GoProperties.hs": "8ee3337141daf223e3a65830803252c220ee76784422b9aca5b6a6c2da701d69",
205
209
  "src/LawSpec/GoTestHelpers.hs": "dee55ee8505370e932773b8c685f4a1f380129e6f43f8806bf1e82efb99451b1",
206
210
  "src/LawSpec/GoTypeRefs.hs": "7f239f5ac3ac8bd21c8f76c328049f7715d8562ee1382befa0a58abd4f15f726",
207
- "src/LawSpec/HaskellData.hs": "fe5d51c89007f1c779a2bd2701d838d115ecb88ab374137996c94988380ebe45",
208
- "src/LawSpec/HaskellDefinitions.hs": "bc3664771247547900fc65f62147048238c3aa477154ac69d7a6e7568b05b2dd",
211
+ "src/LawSpec/HaskellData.hs": "992b910f6231b8482ef52fa8a70ba0247d46de9207ba9853c884d8a1a30b4757",
212
+ "src/LawSpec/HaskellDefinitions.hs": "9bd84e146e89e11f614624084da6bbc76da9229c517494b15a0225706218df32",
209
213
  "src/LawSpec/HaskellExpr.hs": "f4144cf2022ef0a3bec6d796ebe7d2f42563e9d25758b9f362cd5545b47e802b",
210
214
  "src/LawSpec/HaskellNativeBinding.hs": "9f98aa0c8659b572bd6486a0e29c4692bc6432db8639fa74a09bbf1b771bbfa6",
211
- "src/LawSpec/HaskellProperties.hs": "5d64d5f45b86b5bb148383588d69ad717b0e158926b76938cc5cef54ed3adecc",
215
+ "src/LawSpec/HaskellProperties.hs": "8cdacc0982f38a5b641430237493fee1cfe393c595c61208a8876c0d2c1de60d",
212
216
  "src/LawSpec/HaskellTestHelpers.hs": "51e59b2abc9e85455e3c8e2c6baadb27e5d319081cb730d2ce56be5dc8053897",
213
217
  "src/LawSpec/HaskellTypeRefs.hs": "2225b2a5e2ab3662e7202d23b24f4d6db48353b35ae28df8acd2b92fd2b97574",
214
218
  "src/LawSpec/Imports.hs": "4e146ae1c2ee54f038b83430f322f8aadaede252a0857345471eb02a91d39ed6",
215
- "src/LawSpec/Indexed.hs": "77d0198459ac5b8aad51d7043ed9759035ba5b819ae0664d3e9dcd51d36cac03",
216
- "src/LawSpec/Inference.hs": "78285145897f03c3c4adc37acf0f490ea779bab3975fb2830628dae3a152fe38",
217
- "src/LawSpec/JavaData.hs": "1538a91fc857f003fade7aed1097c0f32aec227883a9e312334a42951e70cf46",
218
- "src/LawSpec/JavaDefinitions.hs": "fc2666e4f9f68b747aa596c0caf0483b9f0a47ec4957bbcd399234e77909588d",
219
+ "src/LawSpec/IndexTerm.hs": "65e7942306f08683ec9f284f76b10ad271f8a909b1ec721da04f6275c9a1d20e",
220
+ "src/LawSpec/Indexed.hs": "1e7ed53653cabc097f75dcf350c81facf9feb30af73f3e21f9344665fc316387",
221
+ "src/LawSpec/Inference.hs": "033f31a162f632f0be95b439cad6f43e07a3aa7b6aff8603e2604ebc7d00fa30",
222
+ "src/LawSpec/JavaData.hs": "99aef6e0b5bd920c93e5b8f27de0fe6216b61c060d8f06778a152c4965f6a13a",
223
+ "src/LawSpec/JavaDefinitions.hs": "32c008ee3dd84e730f1510fe604f309f735a9adaa8cbb6417cca2bd4555acbdf",
219
224
  "src/LawSpec/JavaExpr.hs": "6f237b0fc1eabe2d53c160f4cb781f8b77b478383f1a77ca4ccc8f08ac0dbcd0",
220
225
  "src/LawSpec/JavaNativeBinding.hs": "9eb52b3be19badda078069bb3d6813d72cad4f0a9bfa708f7404e44201d3c352",
221
- "src/LawSpec/JavaProperties.hs": "d953771df667aa193b110dbc898b0936b9ff5a32f6ebc9d2ff25d44a6cd4dfec",
226
+ "src/LawSpec/JavaProperties.hs": "abf73af6781677e44295770ec39706a501d79106bd374554f043abd344502b87",
222
227
  "src/LawSpec/JavaTestHelpers.hs": "e6f4b9bbb7e5f07ece6ab1845e12aa661e62e8b926680b11454223fc3ec1523d",
223
- "src/LawSpec/KotlinData.hs": "8832e984f34d805fd315da4bd37edd08add4d9c93d55a34eb97cf2e8651e3a8b",
228
+ "src/LawSpec/KotlinData.hs": "df643527b134915583ca4758b8e75694d92df400cee30a9e0304c50ab25afc33",
224
229
  "src/LawSpec/KotlinDefinitions.hs": "97d7d407d4bbdb4ce16035d607dbbcb8e3d6f5db513f2123a2c269e3dc6d2b38",
225
230
  "src/LawSpec/KotlinExpr.hs": "20312f0774f1d0832a21a19b93c8103e2791ecd32a827d8e9c4f2b4830a996a0",
226
231
  "src/LawSpec/KotlinNativeBinding.hs": "1aec7854758f07a4d2288de13931fbb88ef32220f85d3c84fe8233ad67b6d095",
227
- "src/LawSpec/KotlinProperties.hs": "ee8c68bc5ee10a601a643356edb1e0a0c50d6e72a4520feaccb716c6f02ac99c",
232
+ "src/LawSpec/KotlinProperties.hs": "b352e7319c820e93846ff8412d0a5c6fd4d46fdd320c8320f10c5d56eee55e9c",
228
233
  "src/LawSpec/KotlinTestHelpers.hs": "74810d65faafc6ed4d64b1fb0596cda4186e586b7144a7441641b798795bc324",
229
- "src/LawSpec/Model.hs": "8d01d937b9ced2047018fa12dc8b06b0d71389c1dd9bd9f4dc5f71613d778b0f",
234
+ "src/LawSpec/Model.hs": "9e7f958016905a03961386db9e3b7af7db6c355519e5e74b311e52a9846c62f5",
230
235
  "src/LawSpec/NativeBinding.hs": "33959b0fd432ad4150f3b685f6438e284b801c2a59d9ef3132486a1cc7c8925a",
231
236
  "src/LawSpec/NativeRequest.hs": "fb2dc88f42424ca520533700eab68c407a5de83807d1b0d8c976e6c4f3d65212",
232
237
  "src/LawSpec/Packages.hs": "161fc68a9959a80762ca4ece405240351e3180ea4dbb2bf148eaca6562fb7c30",
233
- "src/LawSpec/Parser.hs": "b99b122a5505667906e05c61da74f1c00dea830dd6936bc35b1d715f797723a2",
238
+ "src/LawSpec/Parser.hs": "7f3da1fab5599acc0ee2bdb61886a88c9ba1c1f3a5380fecb4f7575fda02d45b",
234
239
  "src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
235
240
  "src/LawSpec/PortableTestHelpers.hs": "8ba4d87183c8c11f6ef1ce21c170127335797154f29fb97ad3429f032a167fd3",
236
241
  "src/LawSpec/Prelude.hs": "b1e155c12f58e7c346551a0c65c5d5af76d045b3f1625977ca2a5d1c97cb8c46",
237
242
  "src/LawSpec/Public.hs": "ac46d7b8c5130faf922f10b402e035901d851bb8a229ea823ce0afaaf3011028",
238
- "src/LawSpec/PythonData.hs": "12a4b5d1e0c44684f99fe11563923efc7d2953a93bec645c71279fbbb4f4d98d",
239
- "src/LawSpec/PythonDefinitions.hs": "30f3d2d71a378e194d62261e0fd1baade5a49ac8b5eaac97578ca015a48ce8e4",
243
+ "src/LawSpec/PythonData.hs": "b9219f28d982a5b8e447477d2bcf8ec04dec1ff266f64544a15f9e4a1861e64f",
244
+ "src/LawSpec/PythonDefinitions.hs": "45eb8dd4b706c41761c2968ee44f8c1d371c2aae90729f2b8374ab3ea342831d",
240
245
  "src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
241
246
  "src/LawSpec/PythonNativeBinding.hs": "4e35ff8781062d0f614e45ea45f98038c8d609ab78bd671cb0a239eaa9db1690",
242
247
  "src/LawSpec/PythonTypes.hs": "d02cea858ced57307a9a1cec7e63f0ee1e1cb5f845b94f58e42df5888ec5edee",
243
248
  "src/LawSpec/Refinement.hs": "3bbdc090f9ebce60d99254dbe93dec6e11bd838df8537df828fd9c768c79d126",
244
- "src/LawSpec/RuntimeSources.hs": "a880283705bac3840b3039322f70923829298d8f05754c7fa51a4a3875baba57",
245
- "src/LawSpec/RustData.hs": "1c6396f19dc02a1e52bf1f055a257b1cfa47b89f2bc9c63c6c02f1b489184678",
249
+ "src/LawSpec/RuntimeSources.hs": "d9a9425a41262849d1d2a86cce8d941915b19d94ead21b8c22c8f7981450365c",
250
+ "src/LawSpec/RustData.hs": "a5433a7421c8e95b3eaff4b3c4d667fa055d2a8d201278a6da698b8d1b17e49f",
246
251
  "src/LawSpec/RustDefinitions.hs": "8c289e2779d7ed623f3578f20974dd9e2016c67734ee1447ed7f4b7c22caedf9",
247
- "src/LawSpec/RustEmit.hs": "d08797ca26180b6ed2884c0576ec7b0265cadc2236a95d8754cfea89bb2940e0",
252
+ "src/LawSpec/RustEmit.hs": "33201e4c787d6015005b0149f4343f0148692ed77b5ee3ddb1f19af0f6ce531e",
248
253
  "src/LawSpec/RustExpr.hs": "04b2ef81417b811c7b98a98acdadab4e588ca8757964a63ba8dc5936c36479e6",
249
254
  "src/LawSpec/RustNativeBinding.hs": "d50d1fb10591ee86129ae49b38a343148c084479e450eef3b320e1efdd55245d",
250
255
  "src/LawSpec/RustNativeGenerators.hs": "a3b1484d9ff0008e4f961aa81d0aa51da57ec0cd7909124e80c98d56aacc8ce9",
251
256
  "src/LawSpec/Scaffold.hs": "2cdaeaa0708803e6abf3b8e9062dfc2fe31e2d3a6df3b252a17b1ad91eb5d8f2",
252
- "src/LawSpec/Scalar.hs": "52e61fec81a337bb5b35e9e6f501446cf0b18bffa6c6af2ddc5aeac2d6e07131",
253
- "src/LawSpec/SpecializeDefinitions.hs": "08f2fe674a5e00d1be396d9edab0dd2c948b7beb12fa99f2a6aba00cbdf01e33",
254
- "src/LawSpec/Testing.hs": "9626e43e4c02a0c88435ffe2d629110a99b1b91e8d0bcaa98b468509da69d438",
255
- "src/LawSpec/WebData.hs": "a5e2d812a4fec81f70e3fb70eb233ea5bce4edfa07ec32dfe450caae2a5baf55",
256
- "src/LawSpec/WebDefinitions.hs": "d654df765e4bafcb1acdd35058f8a510c2cd81920153c0a75ff1e7e1137c96e5",
257
+ "src/LawSpec/Scalar.hs": "f7eddc660dbc08d315d85291e446ed5c34670e2321f9268ba852ebf65e206141",
258
+ "src/LawSpec/SpecializeDefinitions.hs": "2bdd6d9b191941d869ef524659e02fed551499aaa2ea98c99323da03af113012",
259
+ "src/LawSpec/Testing.hs": "9aeefd6cbe5a8bd07ae61dc4cc50fc0843e303f738cc9bf78c66a087b82f454b",
260
+ "src/LawSpec/WebData.hs": "38df88584c5c24c4c1e8a4891161e6fc0a7cca135d10f6d7622d295b378587a3",
261
+ "src/LawSpec/WebDefinitions.hs": "3d86a6d0dc3749931d84812a69765934975cde38bc9280961a5dcce9355ae06e",
257
262
  "src/LawSpec/WebExpr.hs": "0389dcd5cf7479dd23ef034b1012de6ebd70bf1dc9e3d90981dfb0ba2702596f",
258
- "src/LawSpec/WebNativeBinding.hs": "465251be1a93d24a775aa57955bb9ec612af7364c53c83017da051f44943eda9",
263
+ "src/LawSpec/WebNativeBinding.hs": "f536c1b1454bc83f5a9e8c61a608390b9a6fa91537f34d3c245b90ee6e275b7d",
259
264
  "src/LawSpec/WebTypes.hs": "f9de8578d5f3a243c06fbabc3efc1b0a776492d01d7faa16d1ed3c0199713aab",
265
+ "src/LawSpec/Witness.hs": "9ae944c9307df964bc853205269c1e4cb69cc076070bb878fc957f4bdb02de85",
260
266
  "stack.yaml": "20ccf4d599e355e60b7aa4f814a7cd4299fe2048616cc2e6dbdc22a7bd8cec73",
261
267
  "stack.yaml.lock": "ae222b9c81af920c56e50fa4596fa57786e7fa5a7b461390362b2b2ff63818c7",
262
268
  "wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
263
269
  "wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
264
270
  "wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
265
- "wasm/lawspec-wasm.cabal": "58af47a3760cd2817577cdb57ed69f377acc13d59d390f56ce60093398d88b2e",
266
- "npm/core.wasm": "ce8b3b976ffab6557eae1f3fc1528bec5fe716b8168429d11be324132a3b9c90",
271
+ "wasm/lawspec-wasm.cabal": "0e16e181813be0aa14f55687f34204817c6ac008bafba9e3ad0b9fd6c2311ecd",
272
+ "npm/core.wasm": "40ad57b5baf29a5acf332c98cb8ea70a4f070a756d94708d1db7b63db05c7a26",
267
273
  "npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
268
274
  "npm/api.mjs": "19e1624f91258c1397f3212faf65b407c62671b0fc5b118520e6a91f7ad7c6ba",
269
275
  "npm/index.d.ts": "2215087cc6628a2ddbdd573210c4f9021cffeb00c142d4f3ae1314fd59a397f6"
package/core.wasm CHANGED
Binary file
@@ -0,0 +1,59 @@
1
+ unit example.flow
2
+
3
+ type Stack (n :: Natural) is
4
+ | Empty where n = 0
5
+ | Push top :: Int8 rest :: Stack m where n = m + 1
6
+ end
7
+
8
+ -- A / A' is a flow parameter: the call takes the stack from A to A'. Each
9
+ -- adapter returns its result with the stack it leaves, as a generated
10
+ -- product (PushFlow, PopFlow, PeekFlow); the stack's index is checked.
11
+ push :: (x :: Int8) -> Stack n / Stack (n + 1) -> Unit
12
+ pop :: Stack (n + 1) / Stack n -> Int8
13
+ peek :: Stack (n + 1) / Stack (n + 1) -> Int8
14
+
15
+ -- A reference definition updates its flow parameter with ~s := e.
16
+ definition pushed (x :: Int8) (s :: Stack n / Stack (n + 1)) :: Unit is
17
+ ~s := Push x s
18
+ end
19
+
20
+ -- ~s passes s to a flow parameter and rebinds s to the stack the call
21
+ -- leaves; e1; e2 sequences, left to right. pop needs Stack (m + 1): after
22
+ -- push, s is a Stack (n + 1), so the pop below type-checks.
23
+ law `pop returns what push pushed` is
24
+ definition is
25
+ `for all` (x :: Int8) (s :: Stack n) . (push x ~s; pop ~s) = x
26
+ end
27
+ end
28
+
29
+ law `push grows the stack` is
30
+ definition is
31
+ `for all` (x :: Int8) (s :: Stack n) . (push x ~s; nOfStack s) = n + 1
32
+ end
33
+ end
34
+
35
+ law `pops come back in reverse` is
36
+ definition is
37
+ `for all` (x :: Int8) (y :: Int8) (s :: Stack n) .
38
+ (push x ~s; push y ~s; pop ~s; pop ~s) = x
39
+ end
40
+ end
41
+
42
+ -- The quantifier's index k + 1 lets peek and pop take s.
43
+ law `peek and pop agree` is
44
+ definition is
45
+ `for all` (s :: Stack (k + 1)) . peek ~s = pop ~s
46
+ end
47
+ end
48
+
49
+ law `pop shrinks the stack` is
50
+ definition is
51
+ `for all` (s :: Stack (k + 1)) . (pop ~s; nOfStack s) = k
52
+ end
53
+ end
54
+
55
+ law `push agrees with the reference` is
56
+ definition is
57
+ `for all` (x :: Int8) (s :: Stack n) . (pushed x ~s; pop ~s) = x
58
+ end
59
+ end
@@ -0,0 +1,76 @@
1
+ unit example.gadt
2
+
3
+ type Pair (a :: Type) (b :: Type) is Pair first :: a second :: b end
4
+
5
+ -- An expression indexed by the type of its value. Each constructor's `where`
6
+ -- fixes that type, so a value of Expr Bool is never a number literal. The
7
+ -- types b and c of Both are existential: Expr (Pair b c) determines them.
8
+ type Expr (a :: Type) is
9
+ | Number value :: BigInt where a = BigInt
10
+ | Truth value :: Bool where a = Bool
11
+ | Plus left :: Expr BigInt right :: Expr BigInt where a = BigInt
12
+ | Same left :: Expr BigInt right :: Expr BigInt where a = Bool
13
+ | Negate operand :: Expr Bool where a = Bool
14
+ | Both first :: Expr b second :: Expr c where a = Pair b c
15
+ end
16
+
17
+ -- Matching Number refines a to BigInt in that branch, so v is a value of a.
18
+ -- eval calls itself at other types (Expr BigInt inside Expr Bool): each type
19
+ -- it is used at becomes a checked instance, and unreachable branches vanish.
20
+ definition eval (e :: Expr a) :: a is
21
+ match e with
22
+ | Number v -> v
23
+ | Truth b -> b
24
+ | Plus l r -> eval l + eval r
25
+ | Same l r -> eval l == eval r
26
+ | Negate x -> !(eval x)
27
+ | Both l r -> Pair (eval l) (eval r)
28
+ end
29
+ end
30
+
31
+ evalNumber :: Expr BigInt -> BigInt
32
+ evalTruth :: Expr Bool -> Bool
33
+ evalPair :: Expr (Pair BigInt Bool) -> Pair BigInt Bool
34
+ -- Constant folding: a single number with the same value.
35
+ fold :: Expr BigInt -> Expr BigInt
36
+
37
+ -- A shown value's type is existential and only the value says what it is:
38
+ -- each value carries its type, as a witness, to native code.
39
+ type Shown is
40
+ | Shown value :: b
41
+ end
42
+
43
+ -- The name of the type a shown value holds.
44
+ describe :: Shown -> Text
45
+
46
+ law `numbers agree with eval` is
47
+ definition is `for all` (e :: Expr BigInt) . evalNumber e = eval e end
48
+ end
49
+
50
+ law `truths agree with eval` is
51
+ definition is `for all` (e :: Expr Bool) . evalTruth e = eval e end
52
+ end
53
+
54
+ law `pairs agree with eval` is
55
+ definition is `for all` (e :: Expr (Pair BigInt Bool)) . evalPair e = eval e end
56
+ end
57
+
58
+ law `folding keeps the value` is
59
+ definition is `for all` (e :: Expr BigInt) . eval (fold e) = eval e end
60
+ end
61
+
62
+ law `a shown number names its type` is
63
+ definition is `for all` (x :: Int32) . describe (Shown x) = "Int32" end
64
+ end
65
+
66
+ law `a shown flag names its type` is
67
+ definition is `for all` (b :: Bool) . describe (Shown b) = "Bool" end
68
+ end
69
+
70
+ law `every shown value is described` is
71
+ definition is `for all` (s :: Shown) . prelude.length (describe s) > 0 end
72
+ end
73
+
74
+ law `two plus three` is
75
+ definition is `for all` (x :: BigInt) . eval (Plus (Number 2) (Number 3)) = 5 end
76
+ end
@@ -0,0 +1,154 @@
1
+ unit example.arithmetic
2
+
3
+ -- Index equations may use natural arithmetic: + - * div mod ^. Subtraction
4
+ -- never truncates, so `m - 1` requires m >= 1 of every value. A variable bound
5
+ -- by several fields makes those fields' indices equal.
6
+ type Row (n :: Natural) is
7
+ | End where n = 0
8
+ | Cell head :: Int8 tail :: Row m where n = m + 1
9
+ end
10
+
11
+ -- A perfect tree: both subtrees share one height.
12
+ type Perfect (n :: Natural) is
13
+ | Leaf value :: Int8 where n = 0
14
+ | Node left :: Perfect m right :: Perfect m where n = m + 1
15
+ end
16
+
17
+ -- A grid's index is its number of cells.
18
+ type Grid (n :: Natural) is
19
+ | Grid rows :: Row r columns :: Row c where n = r * c
20
+ end
21
+
22
+ -- Two halves of one length.
23
+ type Halves (n :: Natural) is
24
+ | Halves front :: Row m back :: Row m where n = m + m
25
+ end
26
+
27
+ -- The number of whole pairs, and the length after the first element.
28
+ type Pairs (n :: Natural) is
29
+ | Pairs items :: Row m where n = m div 2
30
+ end
31
+
32
+ type Rest (n :: Natural) is
33
+ | Rest items :: Row m where n = m - 1
34
+ end
35
+
36
+ mirror :: (tree :: Perfect n) -> (r :: Perfect n)
37
+ area :: (grid :: Grid n) -> BigInt
38
+ duplicate :: (xs :: Row m) -> (r :: Halves (m + m))
39
+ countPairs :: (xs :: Row m) -> (r :: Pairs (m div 2))
40
+ -- `k + 1` binds k to one less than the argument's length.
41
+ dropFirst :: (xs :: Row (k + 1)) -> (r :: Rest k)
42
+
43
+ -- Checked definitions. Matching a Node tells the prover its subtrees share a
44
+ -- height, so mirrorP's result height is proved; so is transposeG's, as r * c
45
+ -- and c * r are the same product. stackRows' claim, (r + r) * c = 2 * (r * c),
46
+ -- is beyond linear arithmetic: it is checked on each result instead.
47
+ definition mirrorP (tree :: Perfect n) :: Perfect n is
48
+ match tree with
49
+ | Leaf v -> Leaf v
50
+ | Node l r -> Node (mirrorP r) (mirrorP l)
51
+ end
52
+ end
53
+
54
+ definition transposeG (grid :: Grid n) :: Grid n is
55
+ match grid with
56
+ | Grid rows columns -> Grid columns rows
57
+ end
58
+ end
59
+
60
+ definition appendRow (xs :: Row n) (ys :: Row m) :: Row (n + m) is
61
+ match xs with
62
+ | End -> ys
63
+ | Cell h t -> Cell h (appendRow t ys)
64
+ end
65
+ end
66
+
67
+ definition stackRows (grid :: Grid n) :: Grid (2 * n) is
68
+ match grid with
69
+ | Grid rows columns -> Grid (appendRow rows rows) columns
70
+ end
71
+ end
72
+
73
+ law `mirror agrees with the proved definition` is
74
+ definition is
75
+ `for all` (tree :: Perfect 3) . mirror tree = mirrorP tree
76
+ end
77
+ end
78
+
79
+ law `transposing keeps the area` is
80
+ definition is
81
+ `for all` (grid :: Grid 12) . area (transposeG grid) = 12
82
+ end
83
+ end
84
+
85
+ law `stacking doubles the area` is
86
+ definition is
87
+ `for all` (grid :: Grid 6) . area (stackRows grid) = 12
88
+ end
89
+ end
90
+
91
+ -- Without an index claim, balanced trees are still generated directly, from a
92
+ -- few small heights; random trees would almost never be balanced.
93
+ law `mirroring twice restores a tree` is
94
+ definition is
95
+ `for all` (tree :: Perfect n) . mirror (mirror tree) = tree
96
+ end
97
+ end
98
+
99
+ law `mirroring keeps the height` is
100
+ definition is
101
+ `for all` (tree :: Perfect 3) . nOfPerfect (mirror tree) = 3
102
+ end
103
+ end
104
+
105
+ law `a grid of six cells` is
106
+ definition is
107
+ `for all` (grid :: Grid 6) . area grid = 6
108
+ end
109
+ end
110
+
111
+ -- Generation chooses rows and columns among the divisors of twelve.
112
+ law `the area is the index` is
113
+ definition is
114
+ `for all` (grid :: Grid 12) . area grid = nOfGrid grid
115
+ end
116
+ end
117
+
118
+ law `duplicating makes equal halves` is
119
+ definition is
120
+ `for all` (xs :: Row m) . nOfHalves (duplicate xs) = m + m
121
+ end
122
+ end
123
+
124
+ -- Generation gives both halves the same length.
125
+ law `halves of six` is
126
+ definition is
127
+ `for all` (halves :: Halves 6) . nOfHalves halves = 6
128
+ end
129
+ end
130
+
131
+ law `seven elements make three pairs` is
132
+ definition is
133
+ `for all` (xs :: Row 7) . nOfPairs (countPairs xs) = 3
134
+ end
135
+ end
136
+
137
+ -- A child may have a larger index than its parent: Pairs 2 holds four or five.
138
+ law `two pairs` is
139
+ definition is
140
+ `for all` (p :: Pairs 2) . nOfPairs p = 2
141
+ end
142
+ end
143
+
144
+ law `the rest is one shorter` is
145
+ definition is
146
+ `for all` (xs :: Row (k + 1)) . nOfRest (dropFirst xs) = k
147
+ end
148
+ end
149
+
150
+ law `the rest of three` is
151
+ definition is
152
+ `for all` (r :: Rest 3) . nOfRest r = 3
153
+ end
154
+ end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lawspec",
3
- "version": "0.15.2",
3
+ "version": "0.16.0",
4
4
  "description": "State the law once. Check it everywhere.",
5
5
  "license": "MIT",
6
6
  "repository": {