├── .gitignore
├── .gitmodules
├── COPYING
├── Makefile
├── README.md
├── config.json
├── findings.md
├── shell.nix
└── src
├── dirty_lemmas.k.md
├── dss.md
├── lemmas.k.md
├── prelude.smt2.md
└── storage.k.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.timestamp
3 | tmp/
4 | out/*
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "dss"]
2 | path = dss
3 | url = https://github.com/makerdao/dss.git
4 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published by
637 | the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | DAPP_DIR = $(CURDIR)/dss
2 | SRC_DIR = $(CURDIR)/src
3 | SRCS = $(addprefix $(SRC_DIR)/, dss.md lemmas.k.md storage.k.md prelude.smt2.md)
4 | DAPP_SRCS = $(wildcard $(DAPP_DIR)/src/*)
5 | # if KLAB_OUT isn't defined, default is to use out/
6 | ifdef KLAB_OUT
7 | OUT_DIR = $(KLAB_OUT)
8 | else
9 | OUT_DIR = $(CURDIR)/out
10 | endif
11 | TMPDIR ?= $(CURDIR)/tmp
12 | ifndef KLAB_EVMS_PATH
13 | $(error $(red)Error$(reset): KLAB_EVMS_PATH must be defined and point to evm-semantics!)
14 | endif
15 | SPECS_DIR = $(OUT_DIR)/specs
16 | ACTS_DIR = $(OUT_DIR)/acts
17 | DOC_DIR = $(OUT_DIR)/doc
18 |
19 | KLAB_FLAGS = KLAB_OUT=$(OUT_DIR)
20 |
21 | SMT_PRELUDE = $(OUT_DIR)/prelude.smt2
22 | RULES = $(OUT_DIR)/rules.k
23 |
24 | SPEC_MANIFEST = $(SPECS_DIR)/specs.manifest
25 |
26 | all: dapp spec
27 |
28 | dapp:
29 | dapp --version
30 | git submodule update --init --recursive
31 | cd $(DAPP_DIR) && dapp --use solc:0.5.9 build && cd ../
32 |
33 | dapp-clean:
34 | cd $(DAPP_DIR) && dapp clean && cd ../
35 |
36 | $(SPEC_MANIFEST): $(SRCS) $(DAPP_SRCS)
37 | mkdir -p $(SPECS_DIR)
38 | $(KLAB_FLAGS) klab build
39 |
40 | spec: $(SPEC_MANIFEST)
41 |
42 | spec-clean:
43 | rm -f $(SPECS_DIR)/* $(ACTS_DIR)/* $(SPEC_MANIFEST)
44 |
45 | $(DOC_DIR)/dss.html: $(SRCS)
46 | $(info Generating html documentation: $@)
47 | mkdir -p $(DOC_DIR)
48 | $(KLAB_FLAGS) klab report > $@
49 |
50 | doc: $(DOC_DIR)/dss.html
51 |
52 | doc-clean:
53 | rm -rf $(DOC_DIR)/*
54 |
55 | log-clean:
56 | rm -rf $(TMPDIR)/klab
57 |
58 | clean: dapp-clean spec-clean doc-clean
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Table of Contents
2 | =================
3 |
4 | * [Installation](#installation)
5 | * [dependencies](#dependencies)
6 | * [build](#build)
7 | * [Usage](#usage)
8 | * [Progress](#progress)
9 | * [Documentation](#documentation)
10 | * [specification format](#specification-format)
11 | * [License](#license)
12 |
13 | This repo contains the formal specification and verification of [multicollateral dai](https://github.com/makerdao/dss).
14 |
15 | The behavior of the contracts is specified in a literate format at [dss.md](src/dss.md), which generates a series of reachability claims, defining `succeeding` and `reverting` behavior for each function of each contract. These reachability claims are then tested against the [formal semantics of the EVM](https://github.com/kframework/evm-semantics) using the [klab](https://github.com/dapphub/klab) tool for interactive proof inspection and debugging.
16 |
17 | An html version of the specification, together with links to in-browser symbolic execution previews, is available at [dapp.ci/k-dss](https://dapp.ci/k-dss)
18 |
19 | # Installation
20 | ## dependencies
21 | * klab. Installation instructions can be found at [klab](https://github.com/dapphub/klab).
22 |
23 | ## build
24 | ```sh
25 | git clone git@github.com:dapphub/k-dss.git
26 | make
27 | ```
28 |
29 | This will download and build the target contracts in `dss/`, and compile the literate specifications in `src/` to K specifications, saving the results in `out/specs`.
30 |
31 | # Usage
32 |
33 | To run a proof with [klab](https://github.com/dapphub/klab), try:
34 |
35 | ```sh
36 | klab prove --dump out/specs/proof-Vat_dai_pass_rough.k
37 | ```
38 |
39 | After it finishes, you can open an interactive debug session to exploring the success behaviour of the `dai()` method of the contract `Vat`:
40 |
41 | ```sh
42 | klab debug $(klab hash out/specs/proof-Vat_dai_pass_rough.k)
43 | ```
44 |
45 | If you aren't interested in exploring with the debugger, you can omit the `--dump` flag for better performance.
46 |
47 | # Progress
48 |
49 | You can inspect the current state of the proofs in the CI running at [dapp.ci](https://dapp.ci/k-dss).
50 |
51 | # Documentation
52 |
53 | To build the literate specification in HTML, run `make doc`. The output of this process is available at [dapp.ci/k-dss](https://dapp.ci/k-dss).
54 |
55 | ## specification format
56 | The format used in [dss.md](src/dss.md) provides a concise way of specifying the behavior of a contract method (see [act-mode](https://github.com/livnev/act-mode) for a simple emacs major mode for `.act` specs).
57 |
58 | Let's break down the specification of the behavior of the function `heal` in the contract `Vat`:
59 |
60 | ```act
61 | behaviour heal of Vat
62 | interface heal(bytes32 u, bytes32 v, int256 rad)
63 |
64 | types
65 |
66 | Can : uint256
67 | Dai_v : uint256
68 | Sin_u : uint256
69 | Debt : uint256
70 | Vice : uint256
71 |
72 | storage
73 |
74 | #Vat.wards(CALLER_ID) |-> Can
75 | #Vat.dai(v) |-> Dai_v => Dai_v - rad
76 | #Vat.sin(u) |-> Sin_u => Sin_u - rad
77 | #Vat.debt |-> Debt => Debt - rad
78 | #Vat.vice |-> Vice => Vice - rad
79 |
80 | iff
81 |
82 | Can == 1
83 |
84 | iff in range uint256
85 |
86 | Dai_v - rad
87 | Sin_u - rad
88 | Debt - rad
89 | Vice - rad
90 | ```
91 |
92 | This snippet of code will generate two reachability claims, `proof-Vat_heal_succ.k` and `proof-Vat_heal_fail.k`. Both of these claims will refer to the bytecode of the contract `Vat` and use the function signature of `heal(bytes32,bytes32,int256)` as the first 4 bytes of calldata (keeping the rest of the calldata abstract). In the `success` spec, the conditions under the `iff` headers are postulated, while in the `fail` spec their negation is.
93 |
94 | The interesting part of this particular function happens under the `storage` header. The meaning of the line:
95 | `#Vat.dai(v) |-> Dai_v => Dai_v - rad`
96 | is that in the `success` case, the value at the storage location which we call `#Vat.dai(v)` will be updated from `Dai_v` to `Dai_v - rad`.
97 |
98 | To prove this reachability claim, the k prover explores all possible execution paths starting from the precondition (whats on the left hand side of a `=>`) and the claim is proven if they all end in a state satisfying the postcondition (right hand side of the `=>`).
99 |
100 | More information about how the K prover and the K Framework in general works can be found at [Semantics-Based Program Verifiers for All Languages](http://fsl.cs.illinois.edu/FSL/papers/2016/stefanescu-park-yuwen-li-rosu-2016-oopsla/stefanescu-park-yuwen-li-rosu-2016-oopsla-public.pdf) and a detailed description of the semantics of EVM defined in K is given in [KEVM: A Complete Semantics of the Ethereum Virtual Machine](https://www.ideals.illinois.edu/handle/2142/97207).
101 |
102 | # License
103 | All applicable work in this repository is licensed under AGPL-3.0. Authors:
104 | * Lev Livnev
105 | * Denis Erfurt
106 | * Martin Lundfall
107 |
--------------------------------------------------------------------------------
/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "k-dss",
3 | "url": "https://github.com/dapphub/k-dss/",
4 | "src": {
5 | "specification": "./src/dss.md",
6 | "smt_prelude": "./src/prelude.smt2.md",
7 | "rules": [
8 | "./src/storage.k.md",
9 | "./src/lemmas.k.md"
10 | ],
11 | "dirty_rules": [
12 | "./src/dirty_lemmas.k.md"
13 | ]
14 | },
15 | "implementations": {
16 | "Vat": {
17 | "src": "src/vat.sol"
18 | },
19 | "Vow": {
20 | "src": "src/vow.sol"
21 | },
22 | "Dai": {
23 | "src": "src/dai.sol"
24 | },
25 | "Jug": {
26 | "src": "src/jug.sol"
27 | },
28 | "Pot": {
29 | "src": "src/pot.sol"
30 | },
31 | "Cat": {
32 | "src": "src/cat.sol"
33 | },
34 | "GemJoin": {
35 | "src": "src/join.sol"
36 | },
37 | "DaiJoin": {
38 | "src": "src/join.sol"
39 | },
40 | "Flipper": {
41 | "src": "src/flip.sol"
42 | },
43 | "Flopper": {
44 | "src": "src/flop.sol"
45 | },
46 | "Flapper": {
47 | "src": "src/flap.sol"
48 | },
49 | "DSToken": {
50 | "src": "lib/ds-token/src/token.sol"
51 | },
52 | "End": {
53 | "src": "src/end.sol"
54 | },
55 | "DSValue": {
56 | "src": "lib/ds-value/src/value.sol"
57 | },
58 | "Spotter": {
59 | "src": "src/spot.sol"
60 | }
61 | },
62 | "split_fail":[
63 | ],
64 | "timeouts": {
65 | "Vat_grab_pass_rough": "16h",
66 | "Vat_grab_fail_rough": "16h",
67 | "Vat_frob-diff-nonzero_pass_rough": "16h",
68 | "Vat_frob-diff-nonzero_fail_rough": "2d",
69 | "Vat_frob-diff-zero-dink_pass_rough": "16h",
70 | "Vat_frob-diff-zero-dink_fail_rough": "2d",
71 | "Vat_frob-diff-zero-dink_pass": "36h",
72 | "Vat_frob-diff-zero-dart_pass_rough": "16h",
73 | "Vat_frob-diff-zero-dart_fail_rough": "2d",
74 | "Vat_frob-diff-zero_pass_rough": "16h",
75 | "Vat_frob-diff-zero_fail_rough": "2d",
76 | "Vat_frob-same-nonzero_pass_rough": "16h",
77 | "Vat_frob-same-nonzero_fail_rough": "2d",
78 | "Vat_frob-same-zero-dink_pass_rough": "16h",
79 | "Vat_frob-same-zero-dink_fail_rough": "2d",
80 | "Vat_frob-same-zero-dink_pass": "2d",
81 | "Vat_frob-same-zero-dart_pass_rough": "16h",
82 | "Vat_frob-same-zero-dart_fail_rough": "2d",
83 | "Vat_frob-same-zero_pass_rough": "16h",
84 | "Vat_frob-same-zero_fail_rough": "2d",
85 | "Vat_fork-diff_pass_rough": "16h",
86 | "Vat_fork-diff_fail_rough": "16h",
87 | "Vat_fork-same_pass_rough": "16h",
88 | "Vat_fork-same_fail_rough": "2d",
89 | "Cat_bite-full_pass_rough": "3d",
90 | "Cat_bite-full_pass": "3d",
91 | "Cat_bite-full_fail_rough": "3d",
92 | "Cat_bite-lump_pass_rough": "3d",
93 | "Cat_bite-lump_pass": "46h",
94 | "Cat_bite-lump_fail_rough": "3d",
95 | "End_free_pass_rough": "16h",
96 | "End_skim_pass_rough": "16h",
97 | "End_skim_fail_rough": "24h",
98 | "End_bail_pass_rough": "16h",
99 | "End_bail_fail_rough": "24h",
100 | "End_skip_pass_rough": "42h",
101 | "End_skip_pass": "42h",
102 | "End_skip_fail_rough": "36h",
103 | "Flipper_dent_fail_rough": "16h",
104 | "Flopper_dent_fail_rough": "16h",
105 | "Flipper_tend_fail_rough": "16h",
106 | "Flapper_tend_fail_rough": "2d",
107 | "Flapper_deal_fail_rough": "16h",
108 | "Pot_drip_fail_rough": "16h",
109 | "Jug_drip_fail_rough": "16h",
110 | "Vow_cage-surplus_fail_rough": "16h",
111 | "Vow_cage-deficit_fail_rough": "16h",
112 | "Vow_cage-balance_fail_rough": "16h",
113 | "End_cage-surplus_fail_rough": "35h",
114 | "End_cage-deficit_fail_rough": "35h",
115 | "End_cage-balance_fail_rough": "35h"
116 | },
117 | "memory" : {
118 | "Vat_frob-diff-nonzero_fail_rough": "25G",
119 | "Vat_frob-diff-zero-dink_fail_rough": "20G",
120 | "Vat_frob-diff-zero-dart_fail_rough": "20G",
121 | "Vat_frob-diff-zero_fail_rough": "20G",
122 | "Vat_frob-same-nonzero_fail_rough": "25G",
123 | "Vat_frob-same-zero_fail_rough": "25G",
124 | "Flapper_tend_fail_rough": "20G",
125 | "Cat_bite-full_pass_rough": "22G",
126 | "Cat_bite-full_pass": "22G",
127 | "Cat_bite-full_fail_rough": "30G",
128 | "Cat_bite-lump_pass_rough": "22G",
129 | "Cat_bite-lump_pass": "22G",
130 | "Cat_bite-lump_fail_rough": "35G",
131 | "End_skip_pass_rough": "20G",
132 | "End_skip_fail_rough": "20G",
133 | "End_skim_fail_rough": "20G",
134 | "End_bail_fail_rough": "20G"
135 | },
136 | "dapp_root": "./dss",
137 | "host": "127.0.0.1:8080"
138 | }
139 |
--------------------------------------------------------------------------------
/findings.md:
--------------------------------------------------------------------------------
1 | frob:
2 |
3 | callData is maybe malformed: ABI_dart is not wrapped in #unsigned
4 |
5 | in general: ***ui proofs don't apply if the i value is not wrapped in unsigned
6 |
--------------------------------------------------------------------------------
/shell.nix:
--------------------------------------------------------------------------------
1 | with import {};
2 | stdenv.mkDerivation {
3 | name = "k-dss";
4 | buildInputs = [
5 | flex
6 | getopt
7 | utillinux
8 | git
9 | gnumake
10 | jq
11 | nodejs
12 | openjdk8
13 | parallel
14 | wget
15 | zip
16 | z3
17 | ];
18 | shellHook = ''
19 | if [ -z "$KLAB_PATH" ]; then echo "WARNING: The environment variable KLAB_PATH should be set to point to the klab repo. Please fix and reënter the nix shell."; fi
20 | export PATH=$KLAB_PATH/node_modules/.bin/:$KLAB_PATH/bin:$PATH
21 | export KLAB_EVMS_PATH=$KLAB_PATH/evm-semantics
22 | '';
23 | }
24 |
--------------------------------------------------------------------------------
/src/dirty_lemmas.k.md:
--------------------------------------------------------------------------------
1 | This is an example for rules that won't affect the proof hashes
2 | this should be "flushed" once in a while to the real lemmas.k file
3 |
4 | ```k
5 | rule WM[ N := #take(X, WS) ] => WM [ N := #asByteStackInWidth(#asWord(#take(X, WS)), X) ]
6 |
7 | rule 0 -Word X => #unsigned(0 -Int X)
8 | requires 0 <=Int X andBool X <=Int pow255
9 | /*
10 | proof:
11 |
12 | 1) rule W0 -Word W1 => chop( (W0 +Int pow256) -Int W1 ) requires W0 I modInt pow256 [concrete, smt-lemma]
14 | 3) rule W0 -Word W1 => chop( W0 -Int W1 ) requires W0 >=Int W1
15 |
16 | Assume X != 0:
17 |
18 | 0 < X : 0 -W X =(1)=> chop( pow256 - X )
19 | 0 < pow256 - X < pow256 : chop( pow256 - X ) =(2)=> pow256 - X
20 |
21 | Assume X == 0:
22 |
23 | 0 == X : 0 -W 0 =(3)=> chop( 0 - 0 )
24 | */
25 |
26 | rule #range(WS [ X := #padToWidth(32, Y) ], Z, 32, WSS) => #range(WS, Z, 32, WSS)
27 | requires Z +Int 32 Z
31 |
32 | //assume ecrec returns an address
33 | rule maxUInt160 &Int #symEcrec(MSG, V, R, S) => #symEcrec(MSG, V, R, S)
34 |
35 | rule 0 <=Int #symEcrec(MSG, V, R, S) => true
36 | rule #symEcrec(MSG, V, R, S) true
37 |
38 | rule A -Word B <=Int A => 0 <=Int A -Int B
39 | requires #rangeUInt(256, A)
40 | andBool #rangeUInt(256, B)
41 |
42 | rule A <=Int chop(A +Int B) => A +Int B <=Int maxUInt256
43 | requires #rangeUInt(256, A)
44 | andBool #rangeUInt(256, B)
45 |
46 | rule #sgnInterp(sgn(chop(A *Int #unsigned(B))) *Int -1, abs(chop(A *Int #unsigned(B))) /Int (pow256 -Int #unsigned(B))) ==K A => #rangeSInt(256, A *Int B)
47 | requires #rangeUInt(256, A)
48 | andBool #rangeSInt(256, B)
49 | andBool B #rangeSInt(256, A *Int B)
52 | requires #rangeUInt(256, A)
53 | andBool #rangeSInt(256, B)
54 | andBool 0 A +Int B
58 | requires #rangeUInt(256, A)
59 | andBool #rangeUInt(256, B)
60 | andBool #rangeUInt(256, A +Int B)
61 |
62 | rule A +Int #unsigned(B) => A
63 | requires B ==K 0
64 |
65 | // lemma for Jug_drip
66 | rule A -Word B => #unsigned(A -Int B)
67 | requires #rangeSInt(256, A)
68 | andBool #rangeSInt(256, B)
69 | andBool 0 <=Int B
70 | andBool 0 <=Int A
71 |
72 | // lemmas for End_skim
73 | rule (A +Int (0 -Int B)) => A -Int B
74 | rule (A *Int (0 -Int B)) => (0 -Int (A *Int B))
75 | rule (A -Int (0 -Int B)) => A +Int B
76 | //lemmas for End_bail
77 | rule (0 -Int A) (0 -Int B) (0 -Int B) <=Int A
81 | requires (notBool #isConcrete(A))
82 | andBool #isConcrete(B)
83 | rule A <=Int (0 -Int B) => B <=Int 0 -Int A
84 | requires (notBool #isConcrete(B))
85 | andBool #isConcrete(A)
86 | rule A B 0 -Int (X *Int Y)
92 | rule (0 -Int X) /Int Y => 0 -Int (X /Int Y)
93 |
94 | rule #unsigned( X *Int Y ) /Int #unsigned( Y ) => X
95 | requires #rangeSInt(256, X *Int Y)
96 | andBool #rangeSInt(256, X)
97 | andBool #rangeSInt(256, Y)
98 | andBool 0 <=Int X
99 | andBool 0 A
102 | requires B ==K 0
103 | andBool #isVariable(A)
104 | andBool #isVariable(B)
105 |
106 | rule A +Int B => B
107 | requires A ==K 0
108 | andBool #isVariable(A)
109 | andBool #isVariable(B)
110 |
111 | // lemma for Cat_bite-full to prevent unsigned(0 - X) devision
112 | rule pow256 -Int #unsigned(0 -Int X) => X
113 | requires X >Int 0
114 |
115 |
116 | // lemma to deal with deep nested calls - gas stuff
117 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (A15 +Int (A16 +Int (A17 +Int (X +Int AS)))))))))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (A15 +Int (A16 +Int (A17 +Int AS)))))))))))))))))
118 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (A15 +Int (A16 +Int (X +Int AS))))))))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (A15 +Int (A16 +Int AS))))))))))))))))
119 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (A15 +Int (X +Int AS)))))))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (A15 +Int AS)))))))))))))))
120 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int (X +Int AS))))))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (A14 +Int AS))))))))))))))
121 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int (X +Int AS)))))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (A13 +Int AS)))))))))))))
122 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int (X +Int AS))))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (A12 +Int AS))))))))))))
123 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int (X +Int AS)))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (A11 +Int AS)))))))))))
124 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int (X +Int AS))))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (A10 +Int AS))))))))))
125 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int (X +Int AS)))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (A9 +Int AS)))))))))
126 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int (X +Int AS))))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (A8 +Int AS))))))))
127 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int (X +Int AS)))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (A7 +Int AS)))))))
128 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int (X +Int AS))))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (A6 +Int AS))))))
129 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int (X +Int AS)))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (A5 +Int AS)))))
130 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int (X +Int AS))))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int (A4 +Int AS))))
131 | rule X -Int (A1 +Int (A2 +Int (A3 +Int (X +Int AS)))) => 0 -Int (A1 +Int (A2 +Int (A3 +Int AS)))
132 | rule X -Int (A1 +Int (A2 +Int (X +Int AS))) => 0 -Int (A1 +Int (A2 +Int AS))
133 |
134 | // Vat_fork-same_fail lemma
135 | rule X +Int (pow256 -Int #unsigned(Y)) => X -Int Y
136 | requires Y 0
140 | requires X #rangeSInt(256, A *Int (0 -Int B))
144 | // requires #rangeUInt(256, A)
145 | // andBool 0 #rangeSInt(256, 0 -Int (A *Int B))
150 | requires #rangeUInt(256, A)
151 | andBool 0 #rangeSInt(256, A *Int (0 -Int B))
155 | requires #rangeUInt256(A)
156 | andBool #rangeUInt256(A *Int B)
157 | andBool 0 =Int 0 => num0(N) >=Int 1
6 | requires N >=Int 1
7 | andBool N modInt 2 ==Int 0
8 |
9 | rule num1(N) >=Int 0 => num1(N) >=Int 1
10 | requires N >Int 1
11 | andBool N modInt 2 =/=Int 0
12 |
13 | rule num0(N /Int 2) => num0(N) -Int 1
14 | requires N >=Int 1
15 | andBool N modInt 2 ==Int 0
16 |
17 | rule num0(N /Int 2) => num0(N)
18 | requires N >=Int 1
19 | andBool N modInt 2 ==Int 1
20 |
21 | rule num1(N /Int 2) => num1(N) -Int 1
22 | requires N >Int 1
23 | andBool N modInt 2 ==Int 1
24 |
25 | rule num1(N /Int 2) => num1(N)
26 | requires N >Int 1
27 | andBool N modInt 2 ==Int 0
28 |
29 | rule num0(N) => 0
30 | requires N ==Int 1
31 |
32 | rule num1(N) => 0
33 | requires N ==Int 1
34 |
35 | rule (#if C #then A #else B #fi *Int X) <=Int maxUInt256 => true
36 | requires A *Int X <=Int maxUInt256
37 | andBool B *Int X <=Int maxUInt256
38 | ```
39 |
40 | ### Solidity Word Packing
41 | We will have to use some of these tricks when reasoning about solidity implementations of `Flip`, `Flap`, and `Flop`:
42 |
43 | ```k
44 | syntax Int ::= "pow48" [function]
45 | syntax Int ::= "pow208" [function]
46 | rule pow48 => 281474976710656 [macro]
47 | rule pow208 => 411376139330301510538742295639337626245683966408394965837152256 [macro]
48 |
49 | syntax Int ::= "#WordPackUInt48UInt48" "(" Int "," Int ")" [function]
50 | // ----------------------------------------------------------
51 | rule #WordPackUInt48UInt48(X, Y) => Y *Int pow48 +Int X
52 | requires #rangeUInt(48, X)
53 | andBool #rangeUInt(48, Y)
54 |
55 | syntax Int ::= "#WordPackAddrUInt48UInt48" "(" Int "," Int "," Int ")" [function]
56 | // ----------------------------------------------------------------------
57 | rule #WordPackAddrUInt48UInt48(A, X, Y) => Y *Int pow208 +Int X *Int pow160 +Int A
58 | requires #rangeAddress(A)
59 | andBool #rangeUInt(48, X)
60 | andBool #rangeUInt(48, Y)
61 |
62 | syntax Int ::= "#WordPackAddrUInt8" "(" Int "," Int ")" [function]
63 | // ----------------------------------------------------------
64 | rule #WordPackAddrUInt8(X, Y) => Y *Int pow160 +Int X
65 | requires #rangeAddress(X)
66 | andBool #rangeUInt(8, Y)
67 | ```
68 |
69 | # dss lemmas
70 |
71 | ### string literal syntax
72 |
73 | ```k
74 |
75 | syntax Int ::= "#string2Word" "(" String ")" [function]
76 | // ----------------------------------------------------
77 | rule #string2Word(S) => #asWord(#padRightToWidth(32, #parseByteStackRaw(S)))
78 | ```
79 |
80 | ### special fixed-point arithmetic
81 |
82 | ```k
83 | syntax Int ::= "#Wad" [function]
84 | // -----------------------------
85 | rule #Wad => 1000000000000000000 [macro]
86 |
87 | syntax Int ::= "#Ray" [function]
88 | // -----------------------------
89 | rule #Ray => 1000000000000000000000000000 [macro]
90 |
91 | syntax Int ::= "#rmul" "(" Int "," Int ")" [function]
92 | rule #rmul(X, Y) => (X *Int Y) /Int #Ray
93 | ```
94 |
95 | We leave these symbolic for now:
96 |
97 | ```k
98 | syntax Int ::= "#rpow" "(" Int "," Int "," Int "," Int ")" [function, smtlib(smt_rpow), smt-prelude]
99 |
100 | syntax Int ::= "#ifInt" Bool "#then" Int "#else" Int "#fi" [function, smtlib(ite), hook(KEQUAL.ite)]
101 |
102 | rule A *Int C /Int C => A
103 | requires A *Int C #ifInt Y ==Int 0 #then 0 #else chop(X) #fi
106 |
107 | rule A /Int B true
108 | requires A Z
111 | requires N ==Int 0
112 |
113 | rule Z *Int (X ^Int (N %Int 2)) => Z
114 | requires N ==Int 0
115 |
116 | rule 0 ^Int N => 1
117 | requires N ==Int 0
118 |
119 | rule 0 ^Int N => 0
120 | requires N >Int 0
121 |
122 | rule 0 <=Int (N /Int 2) => true
123 | requires 0 <=Int N
124 |
125 | rule N /Int 2 true
126 | requires N X *Int X
130 | requires #rpow(Z, X, N, B) *Int B =Int 2
132 |
133 |
134 | rule #rpow(Z, X, 0, Base) => Z
135 |
136 | rule #rpow(Z, X, N, Base) => Z
137 | requires N modInt 2 ==Int 0
138 | andBool N /Int 2 ==Int 0
139 |
140 | rule #rpow(Z, 0, N, Base) => 0
141 |
142 | rule #rpow(Base, X, N, Base) => X
143 | requires N ==Int 1
144 |
145 | rule #rpow(((Z *Int X) +Int Half) /Int Base, X, N /Int 2, Base) =>
146 | #rpow(Z, X, N, Base)
147 | requires Half ==Int Base /Int 2
148 | andBool N ==Int 1
149 |
150 | rule #rpow(((Z *Int X) +Int Half) /Int Base, ((X *Int X) +Int Half) /Int Base, N /Int 2, Base) =>
151 | #rpow( Z , X , N , Base )
152 | requires N modInt 2 =/=Int 0
153 | andBool N >=Int 2
154 | andBool Half ==Int Base /Int 2
155 |
156 | rule #rpow( Z , ((X *Int X) +Int Half) /Int Base, N /Int 2, Base) =>
157 | #rpow( Z , X , N , Base )
158 | requires N modInt 2 ==Int 0
159 | andBool N >=Int 2
160 | andBool Half ==Int Base /Int 2
161 |
162 | rule #rpow( X , ((X *Int X) +Int Half) /Int Base, N /Int 2, Base) =>
163 | #rpow( Base , X , N , Base )
164 | requires N modInt 2 =/=Int 0
165 | andBool N /Int 2 =/=Int 0
166 | andBool Half ==Int Base /Int 2
167 |
168 | rule Z *Int X true
169 | requires #rpow(Z, X, N, Base) keccakIntList(L) +Int N
177 | requires N <=Int 100
178 |
179 | // solidity also needs:
180 | rule chop(keccakIntList(L)) => keccakIntList(L)
181 | // and
182 | rule chop(N +Int keccakIntList(L)) => keccakIntList(L) +Int N
183 | requires N <=Int 100
184 | ```
185 |
186 | ### solidity masking
187 |
188 | **TODO**: refactor and tidy these.
189 |
190 | ```k
191 | syntax Int ::= "Mask12_32" [function]
192 | syntax Int ::= "Mask0_6" [function]
193 | syntax Int ::= "Mask6_12" [function]
194 | syntax Int ::= "Mask0_12" [function]
195 | syntax Int ::= "Mask0_26" [function]
196 | syntax Int ::= "Mask26_32" [function]
197 | syntax Int ::= "Mask20_26" [function]
198 | // -----------------------------------
199 | // 0x000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff
200 | rule Mask0_6 => 411376139330301510538742295639337626245683966408394965837152255 [macro]
201 | // 0xffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff
202 | rule Mask6_12 => 115792089237315784047431654708638870748305248246218003188207458632603225030655 [macro]
203 | // 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff
204 | rule Mask0_12 => 1461501637330902918203684832716283019655932542975 [macro]
205 | // 0xffffffffffffffffffffffff0000000000000000000000000000000000000000
206 | rule Mask12_32 => 115792089237316195423570985007226406215939081747436879206741300988257197096960 [macro]
207 | // 0x0000000000000000000000000000000000000000000000000000ffffffffffff
208 | rule Mask0_26 => 281474976710655 [macro]
209 | // 0xffffffffffffffffffffffffffffffffffffffff000000000000ffffffffffff
210 | rule Mask20_26 => 115792089237316195423570985008687907853269984665561335876943319951794562400255 [macro]
211 | // 0xffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000
212 | rule Mask26_32 => 115792089237316195423570985008687907853269984665640564039457583726438152929280 [macro]
213 |
214 | syntax Int ::= "maxUInt208" [function]
215 | rule maxUInt208 => 411376139330301510538742295639337626245683966408394965837152255 [macro]
216 |
217 | rule maxUInt208 &Int ((X *Int pow208) +Int A ) => A
218 | requires #rangeAddress(A)
219 | andBool #rangeUInt(48, X)
220 |
221 | rule (X *Int pow208) |Int A => (X *Int pow208 +Int A)
222 | requires #rangeUInt(48, X)
223 | andBool #rangeAddress(A)
224 |
225 | rule Mask26_32 &Int (Y *Int pow48 +Int X) => Y *Int pow48
226 | requires #rangeUInt(48, X)
227 | andBool #rangeUInt(48, Y)
228 |
229 | rule Mask20_26 &Int (Y *Int pow48 +Int X) => X
230 | requires #rangeUInt(48, X)
231 | andBool #rangeUInt(48, Y)
232 |
233 | rule X |Int Y *Int pow48 => Y *Int pow48 +Int X
234 | requires #rangeUInt(48, Y)
235 | andBool #rangeUInt(48, X)
236 |
237 | rule (X *Int pow48) |Int Y => (X *Int pow48) +Int Y
238 | requires #rangeUInt(48, Y)
239 | andBool #rangeUInt(48, X)
240 |
241 | rule Mask12_32 &Int A => 0
242 | requires #rangeAddress(A)
243 |
244 | rule X |Int 0 => X
245 |
246 | rule chop(A &Int B) => A &Int B
247 | requires #rangeUInt(256, A)
248 | andBool #rangeUInt(256, B)
249 |
250 | rule chop(A |Int B) => A |Int B
251 | requires #rangeUInt(256, A)
252 | andBool #rangeUInt(256, B)
253 |
254 | // Masking for packed words
255 | rule Mask12_32 &Int (Y *Int pow208 +Int (X *Int pow160 +Int A)) => Y *Int pow208 +Int X *Int pow160
256 | requires #rangeAddress(A)
257 | andBool #rangeUInt(48, X)
258 | andBool #rangeUInt(48, Y)
259 |
260 | rule B |Int (Y *Int pow208 +Int X *Int pow160) => Y *Int pow208 +Int X *Int pow160 +Int B
261 | requires #rangeAddress(B)
262 | andBool #rangeUInt(48, X)
263 | andBool #rangeUInt(48, Y)
264 |
265 | rule (Y *Int pow208 +Int ( X *Int pow160 +Int A ) ) /Int pow208 => Y
266 | requires #rangeAddress(A)
267 | andBool #rangeUInt(48, X)
268 | andBool #rangeUInt(48, Y)
269 |
270 | rule (Y *Int pow48 +Int X) /Int pow48 => Y
271 | requires #rangeUInt(48, X)
272 | andBool #rangeUInt(48, Y)
273 |
274 | rule Mask0_6 &Int (X *Int pow208 +Int ( Y *Int pow160 +Int A ) ) => Y *Int pow160 +Int A
275 | requires #rangeUInt(48, X)
276 | andBool #rangeUInt(48, Y)
277 | andBool #rangeAddress(A)
278 |
279 | rule Mask6_12 &Int (Y *Int pow208 +Int ( X *Int pow160 +Int A) ) => Y *Int pow208 +Int A
280 | requires #rangeAddress(A)
281 | andBool #rangeUInt(48, X)
282 | andBool #rangeUInt(48, Y)
283 |
284 | rule (Y *Int pow208) |Int (X *Int pow160 +Int A) => Y *Int pow208 +Int X *Int pow160 +Int A
285 | requires #rangeAddress(A)
286 | andBool #rangeUInt(48, X)
287 | andBool #rangeUInt(48, Y)
288 |
289 | rule (X *Int pow160) |Int (Y *Int pow208 +Int A) => Y *Int pow208 +Int X *Int pow160 +Int A
290 | requires #rangeAddress(A)
291 | andBool #rangeUInt(48, X)
292 | andBool #rangeUInt(48, Y)
293 |
294 | rule maxUInt160 &Int ((X *Int pow208) +Int ((Y *Int pow160) +Int A)) => A
295 | requires #rangeAddress(A)
296 | andBool #rangeUInt(48, X)
297 | andBool #rangeUInt(48, Y)
298 |
299 | rule maxUInt160 &Int ((X *Int pow208) +Int (Y *Int pow160)) => 0
300 | requires #rangeUInt(48, X)
301 | andBool #rangeUInt(48, Y)
302 |
303 | rule maxUInt160 &Int ((X *Int pow208) +Int A) => A
304 | requires #rangeAddress(A)
305 | andBool #rangeUInt(48, X)
306 |
307 | rule maxUInt160 &Int ((X *Int pow160) +Int A) => A
308 | requires #rangeAddress(A)
309 | andBool #rangeUInt(48, X)
310 |
311 | rule maxUInt160 &Int (X *Int pow208) => 0
312 | requires #rangeUInt(48, X)
313 |
314 | rule maxUInt160 &Int (X *Int pow160) => 0
315 | requires #rangeUInt(48, X)
316 |
317 | rule (((X *Int pow208) +Int ( (Y *Int pow160) +Int A)) /Int pow160) => (X *Int pow48) +Int Y
318 | requires #rangeAddress(A)
319 | andBool #rangeUInt(48, X)
320 | andBool #rangeUInt(48, Y)
321 |
322 | rule maxUInt48 &Int (X *Int pow48) +Int Y => Y
323 | requires #rangeUInt(48, X)
324 | andBool #rangeUInt(48, Y)
325 |
326 | rule ((X *Int pow208) +Int A) /Int pow160 => X *Int pow48
327 | requires #rangeAddress(A)
328 | andBool #rangeUInt(48, X)
329 |
330 | rule ((X *Int pow160) +Int A) /Int pow160 => X
331 | requires #rangeAddress(A)
332 |
333 | rule (Y *Int pow208 +Int X *Int pow160) /Int pow208 => Y
334 | requires #rangeUInt(48, X)
335 |
336 | rule (Y *Int pow208 +Int A) /Int pow208 => Y
337 | requires #rangeAddress(A)
338 |
339 | rule maxUInt48 &Int (X *Int pow48) => 0
340 | requires #rangeUInt(48, X)
341 | ```
342 |
343 | ### miscellaneous
344 |
345 | ```k
346 | rule WS ++ .WordStack => WS
347 |
348 | rule #sizeWordStack ( #padToWidth ( 32 , #asByteStack ( #unsigned ( W ) ) ) , 0) => 32
349 | requires #rangeSInt(256, W)
350 |
351 | // custom ones:
352 | rule #asWord(#padToWidth(32, #asByteStack(#unsigned(X)))) => #unsigned(X)
353 | requires #rangeSInt(256, X)
354 |
355 | // rule #take(N, #padToWidth(N, WS) ++ WS' ) => #padToWidth(N, WS)
356 |
357 | // potentially useful
358 | // rule #padToWidth(N, WS) ++ WS' => #padToWidth(N + #sizeWordStack(WS'), WS ++ WS')
359 | // and the N, M versions
360 |
361 | rule #take(N, #padToWidth(N, WS) ) => #padToWidth(N, WS)
362 | ```
363 |
364 | ### 48-bit integer arithmetic
365 |
366 | ```k
367 | rule notBool((Mask0_26 &Int (A +Int B)) A +Int B <=Int maxUInt48
368 | requires #rangeUInt(48, A)
369 | andBool #rangeUInt(48, B)
370 | ```
371 |
372 | ### signed 256-bit integer arithmetic
373 |
374 | ```k
375 | rule #unsigned(X) ==K 0 => X ==Int 0
376 | requires #rangeSInt(256, X)
377 |
378 | // rule 0 0 0 <=Int A -Int B
384 | // requires #rangeUInt(256, A)
385 | // andBool #rangeUInt(256, B)
386 |
387 | // addui
388 | // lemmas for sufficiency
389 | rule chop(A +Int #unsigned(B)) => A +Int B
390 | requires #rangeUInt(256, A)
391 | andBool #rangeSInt(256, B)
392 | andBool #rangeUInt(256, A +Int B)
393 |
394 | rule A <=Int chop(A +Int #unsigned(B)) => A +Int B <=Int maxUInt256
395 | requires #rangeUInt(256, A)
396 | andBool #rangeSInt(256, B)
397 | andBool 0 0 <=Int A +Int B
400 | requires #rangeUInt(256, A)
401 | andBool #rangeSInt(256, B)
402 | andBool B (A +Int B <=Int maxUInt256)
405 | // requires #rangeUInt(256, A)
406 | // andBool #rangeSInt(256, B)
407 | // andBool B >=Int 0
408 |
409 | // rule A <=Int chop(A +Int #unsigned(B)) => A +Int B A -Int B
417 | requires #rangeUInt(256, A)
418 | andBool #rangeSInt(256, B)
419 | andBool #rangeUInt(256, A -Int B)
420 |
421 | rule A -Word #unsigned(B) <=Int A => minUInt256 <=Int A -Int B
422 | requires #rangeUInt(256, A)
423 | andBool #rangeSInt(256, B)
424 | andBool 0 <=Int B
425 |
426 | rule A A -Int B <=Int maxUInt256
427 | requires #rangeUInt(256, A)
428 | andBool #rangeSInt(256, B)
429 | andBool B maxUInt256 A -Int B
437 | requires #rangeUInt(256, A)
438 | andBool #rangeSInt(256, B)
439 | andBool #rangeUInt(256, A -Int B)
440 | andBool B #unsigned(A *Int B)
445 | requires #rangeUInt(256, A)
446 | andBool #rangeSInt(256, B)
447 | andBool #rangeSInt(256, A *Int B)
448 |
449 | rule abs(#unsigned(A *Int B)) /Int abs(#unsigned(B)) => A
450 | requires #rangeUInt(256, A)
451 | andBool #rangeSInt(256, B)
452 | andBool #rangeSInt(256, A *Int B)
453 | andBool notBool (#unsigned(B) ==Int 0)
454 |
455 |
456 | rule abs(B) ==K 0 => B ==K 0
457 |
458 | rule #sgnInterp(sgn(#unsigned(A *Int B)) *Int sgn(#unsigned(B)), A) => A
459 | requires #rangeSInt(256, A *Int B)
460 | andBool #rangeUInt(256, A)
461 | andBool #rangeSInt(256, B)
462 |
463 | // lemmas for necessity
464 | rule #signed(X) notBool #rangeSInt(256, X)
465 | requires #rangeUInt(256, X)
466 |
467 | // rule #sgnInterp(sgn(chop(A *Int B)), abs(chop(A *Int B)) /Int B) ==K A => #rangeSInt(256, A *Int B)
468 | // requires #rangeUInt(256, A)
469 | // andBool #rangeSInt(256, B)
470 |
471 | // rule #sgnInterp(sgn(chop(A *Int (pow256 +Int B))) *Int -1, chop(abs(chop(A *Int (pow256 +Int B))) /Int (pow256 -Int (pow256 +Int B)))) ==K A => #rangeSInt(256, A *Int B)
472 | // requires #rangeUInt(256, A)
473 | // andBool #rangeSInt(256, B)
474 |
475 | rule (chop(A *Int B) /Int B ==K A) => #rangeUInt(256, A *Int B)
476 | requires #rangeUInt(256, A)
477 | andBool #rangeUInt(256, B)
478 |
479 | rule (#sgnInterp(sgn(chop(A *Int #unsigned(B))) *Int sgn(#unsigned(B)), abs(chop(A *Int #unsigned(B))) /Int abs(#unsigned(B))) ==K A) => #rangeSInt(256, A *Int B)
480 | requires #rangeUInt(256, A)
481 | andBool #rangeSInt(256, B)
482 | andBool B =/=Int 0
483 | ```
484 |
--------------------------------------------------------------------------------
/src/prelude.smt2.md:
--------------------------------------------------------------------------------
1 | ```smt2
2 |
3 | (set-option :auto-config false)
4 | (set-option :smt.mbqi false)
5 | ;(set-option :smt.mbqi.max_iterations 15)
6 |
7 | ; (set-option :auto-config false)
8 | ; (set-option :smt.mbqi false)
9 | ; (set-option :smt.array.extensional false)
10 |
11 | ; int extra
12 | (define-fun int_max ((x Int) (y Int)) Int (ite (< x y) y x))
13 | (define-fun int_min ((x Int) (y Int)) Int (ite (< x y) x y))
14 | (define-fun int_abs ((x Int)) Int (ite (< x 0) (- 0 x) x))
15 |
16 | ; bool to int
17 | (define-fun smt_bool2int ((b Bool)) Int (ite b 1 0))
18 |
19 | ; ceil32
20 | (define-fun ceil32 ((x Int)) Int ( * ( div ( + x 31 ) 32 ) 32 ) )
21 |
22 | ;; pow256 and pow255
23 | (define-fun pow256 () Int
24 | 115792089237316195423570985008687907853269984665640564039457584007913129639936)
25 | (define-fun pow255 () Int
26 | 57896044618658097711785492504343953926634992332820282019728792003956564819968)
27 | ;; weird declaration trick (doesn't seem to be needed currently)
28 | ;; (declare-fun pow256 () Int)
29 | ;; (assert (>= pow256 115792089237316195423570985008687907853269984665640564039457584007913129639936))
30 | ;; (assert (<= pow256 115792089237316195423570985008687907853269984665640564039457584007913129639936))
31 |
32 | ;; signed word arithmetic definitions:
33 | ;; integer to word:
34 | (define-fun unsigned ((x Int)) Int
35 | (if (>= x 0)
36 | x
37 | (+ x pow256)))
38 |
39 | ;; word to integer
40 | (define-fun signed ((x Int)) Int
41 | (if (< x pow255)
42 | x
43 | (- x pow256)))
44 |
45 | ;; signed_abs
46 | (define-fun signed_abs ((x Int)) Int
47 | (if (< x pow255)
48 | x
49 | (- pow256 x)))
50 |
51 | ;; signed_sgn
52 | (define-fun signed_sgn ((x Int)) Int
53 | (if (< x pow255)
54 | 1
55 | -1))
56 |
57 | ;; smt_rpow
58 | (declare-fun smt_rpow (Int Int Int Int) Int)
59 | (assert (forall ((z Int) (x Int) (y Int) (b Int)) (! (=> (= y 1) (= (smt_rpow z x y b) (div (+ (* z x) (div b 2)) b))) :pattern ((smt_rpow z x y b)))))
60 |
61 | (assert (forall ((z1 Int) (z2 Int) (x1 Int) (y1 Int) (x2 Int) (y2 Int) (b1 Int) (b2 Int))
62 | (!
63 | (=> (and (<= z1 z2) (<= x1 x2) (<= y1 y2) (<= b1 b2))
64 | (<= (smt_rpow z1 x1 y1 b1) (smt_rpow z2 x2 y2 b2))
65 | )
66 | :pattern ((smt_rpow z1 x1 y1 b1) (smt_rpow z2 x2 y2 b2))
67 | )
68 | ))
69 |
70 | (assert (forall ((z Int) (x Int) (y Int) (b Int)) (! (=> (>= y 1) (>= (* (smt_rpow z x y b) b) (* z x))) :pattern ((smt_rpow z x y b)))))
71 | (assert (forall ((z Int) (x Int) (y Int) (b Int)) (! (=> (>= y 2) (>= (* (smt_rpow z x y b) b) (* x x))) :pattern ((smt_rpow z x y b)))))
72 |
73 | (assert (forall ((z Int) (x Int) (y Int) (b Int)) (! (=> (>= y 1) (>= (* (smt_rpow z x y b) b) (+ (* z x) (div b 2)))) :pattern ((smt_rpow z x y b)))))
74 | (assert (forall ((z Int) (x Int) (y Int) (b Int)) (! (=> (>= y 2) (>= (* (smt_rpow z x y b) b) (+ (* x x) (div b 2)))) :pattern ((smt_rpow z x y b)))))
75 | ;
76 | ; end of prelude
77 | ;
78 | ```
79 |
--------------------------------------------------------------------------------
/src/storage.k.md:
--------------------------------------------------------------------------------
1 | # dss storage model
2 |
3 | ### Vat
4 |
5 | ```k
6 | // act: public
7 | syntax Int ::= "#Vat.wards" "[" Int "]" [function]
8 | // -----------------------------------------------
9 | // doc: whether `$0` is an owner of `Vat`
10 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
11 | rule #Vat.wards[A] => #hashedLocation("Solidity", 0, A)
12 |
13 | syntax Int ::= "#Vat.can" "[" Int "][" Int "]" [function]
14 | // -----------------------------------------------
15 | // doc: whether `$1` can spend the resources of `$0`
16 | // act: address `$0` has authorized `$1`
17 | rule #Vat.can[A][B] => #hashedLocation("Solidity", 1, A B)
18 |
19 | syntax Int ::= "#Vat.ilks" "[" Int "].Art" [function]
20 | // ----------------------------------------------------
21 | // doc: total debt units issued from `$0`
22 | // act: `$0` has debt issuance `.`
23 | rule #Vat.ilks[Ilk].Art => #hashedLocation("Solidity", 2, Ilk) +Int 0
24 |
25 | syntax Int ::= "#Vat.ilks" "[" Int "].rate" [function]
26 | // ----------------------------------------------------
27 | // doc: debt unit rate of `$0`
28 | // act: `$0` has debt unit rate `.`
29 | rule #Vat.ilks[Ilk].rate => #hashedLocation("Solidity", 2, Ilk) +Int 1
30 |
31 | syntax Int ::= "#Vat.ilks" "[" Int "].spot" [function]
32 | // -----------------------------------------------
33 | // doc: price with safety margin for `$0`
34 | // act: `$0` has safety margin `.`
35 | rule #Vat.ilks[Ilk].spot => #hashedLocation("Solidity", 2, Ilk) +Int 2
36 |
37 | syntax Int ::= "#Vat.ilks" "[" Int "].line" [function]
38 | // -----------------------------------------------
39 | // doc: debt ceiling for `$0`
40 | // act: `$0` has debt ceiling `.`
41 | rule #Vat.ilks[Ilk].line => #hashedLocation("Solidity", 2, Ilk) +Int 3
42 |
43 | syntax Int ::= "#Vat.ilks" "[" Int "].dust" [function]
44 | // -----------------------------------------------
45 | // doc: urn debt floor for `$0`
46 | // act: `$0` has debt floor `.`
47 | rule #Vat.ilks[Ilk].dust => #hashedLocation("Solidity", 2, Ilk) +Int 4
48 |
49 | syntax Int ::= "#Vat.urns" "[" Int "][" Int "].ink" [function]
50 | // ----------------------------------------------------------
51 | // doc: locked collateral units in `$0` assigned to `$1`
52 | // act: agent `$1` has `.` collateral units in `$0`
53 | rule #Vat.urns[Ilk][Usr].ink => #hashedLocation("Solidity", 3, Ilk Usr)
54 |
55 | syntax Int ::= "#Vat.urns" "[" Int "][" Int "].art" [function]
56 | // ----------------------------------------------------------
57 | // doc: debt units in `$0` assigned to `$1`
58 | // act: agent `$1` has `.` debt units in `$0`
59 | rule #Vat.urns[Ilk][Usr].art => #hashedLocation("Solidity", 3, Ilk Usr) +Int 1
60 |
61 | syntax Int ::= "#Vat.gem" "[" Int "][" Int "]" [function]
62 | // ---------------------------------------------
63 | // doc: unlocked collateral in `$0` assigned to `$1`
64 | // act: agent `$1` has `.` unlocked collateral in `$0`
65 | rule #Vat.gem[Ilk][Usr] => #hashedLocation("Solidity", 4, Ilk Usr)
66 |
67 | syntax Int ::= "#Vat.dai" "[" Int "]" [function]
68 | // ---------------------------------------------
69 | // doc: dai assigned to `$0`
70 | // act: agent `$0` has `.` dai
71 | rule #Vat.dai[A] => #hashedLocation("Solidity", 5, A)
72 |
73 | syntax Int ::= "#Vat.sin" "[" Int "]" [function]
74 | // ---------------------------------------------
75 | // doc: system debt assigned to `$0`
76 | // act: agent `$0` has `.` dai
77 | rule #Vat.sin[A] => #hashedLocation("Solidity", 6, A)
78 |
79 | syntax Int ::= "#Vat.debt" [function]
80 | // ---------------------------------
81 | // doc: total dai issued from the system
82 | // act: there is `.` dai in total
83 | rule #Vat.debt => 7
84 |
85 | syntax Int ::= "#Vat.vice" [function]
86 | // ----------------------------------
87 | // doc: total system debt
88 | // act: there is `.` system debt
89 | rule #Vat.vice => 8
90 |
91 | syntax Int ::= "#Vat.Line" [function]
92 | // ----------------------------------
93 | // doc: global debt ceiling
94 | // act: the global debt ceiling is `.`
95 | rule #Vat.Line => 9
96 |
97 | syntax Int ::= "#Vat.live" [function]
98 | // ----------------------------------
99 | // doc: system status
100 | // act: the system is `. == 1 ? : not` live
101 | rule #Vat.live => 10
102 | ```
103 |
104 | ### Dai
105 |
106 | ```k
107 | syntax Int ::= "#Dai.wards" "[" Int "]" [function]
108 | // -----------------------------------------------
109 | // doc: whether `$0` is an owner of `Vat`
110 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
111 | rule #Dai.wards[A] => #hashedLocation("Solidity", 0, A)
112 |
113 | syntax Int ::= "#Dai.totalSupply" [function]
114 | // -----------------------------------------------
115 | // doc: the total supply of this token
116 | // act: the total supply is .`
117 | rule #Dai.totalSupply => 1
118 |
119 | syntax Int ::= "#Dai.balanceOf" "[" Int "]" [function]
120 | // -----------------------------------------------
121 | // doc: the balance of a user
122 | // act: the balance of `$0 is .` us ,
123 | rule #Dai.balanceOf[A] => #hashedLocation("Solidity", 2, A)
124 |
125 | syntax Int ::= "#Dai.allowance" "[" Int "][" Int "]" [function]
126 | // -----------------------------------------------
127 | // doc: the amount that can be spent on someones behalf
128 | // act: `$1 can spend `.` tokens belonging to `$0`
129 | rule #Dai.allowance[A][B] => #hashedLocation("Solidity", 3, A B)
130 |
131 | syntax Int ::= "#Dai.nonces" "[" Int "]" [function]
132 | // -----------------------------------------------
133 | // doc: the amount that can be spent on someones behalf
134 | // act: `$1 can spend `.` tokens belonging to `$0`
135 | rule #Dai.nonces[A] => #hashedLocation("Solidity", 4, A)
136 |
137 | syntax Int ::= "#Dai.DOMAIN_SEPARATOR" [function]
138 | // -----------------------------------------------
139 | // doc: the amount that can be spent on someones behalf
140 | // act: `$1 can spend `.` tokens belonging to `$0`
141 | rule #Dai.DOMAIN_SEPARATOR => 5
142 | ```
143 |
144 | ### Jug
145 |
146 | ```k
147 | syntax Int ::= "#Jug.wards" "[" Int "]" [function]
148 | // -----------------------------------------------
149 | // doc: whether `$0` is an owner of `Jug`
150 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
151 | rule #Jug.wards[A] => #hashedLocation("Solidity", 0, A)
152 |
153 | syntax Int ::= "#Jug.ilks" "[" Int "].duty" [function]
154 | // ----------------------------------------------------
155 | // doc:
156 | // act:
157 | rule #Jug.ilks[Ilk].duty => #hashedLocation("Solidity", 1, Ilk) +Int 0
158 |
159 | syntax Int ::= "#Jug.ilks" "[" Int "].rho" [function]
160 | // ----------------------------------------------------
161 | // doc:
162 | // act:
163 | rule #Jug.ilks[Ilk].rho => #hashedLocation("Solidity", 1, Ilk) +Int 1
164 |
165 | syntax Int ::= "#Jug.vat" [function]
166 | // ----------------------------------
167 | // doc: `Vat` that this `Jug` points to
168 | // act: this Jug points to Vat `.`
169 | rule #Jug.vat => 2
170 |
171 | syntax Int ::= "#Jug.vow" [function]
172 | // ----------------------------------
173 | // doc: `Vow` that this `Jug` points to
174 | // act: this Jug points to Vow `.`
175 | rule #Jug.vow => 3
176 |
177 | syntax Int ::= "#Jug.base" [function]
178 | // ----------------------------------
179 | // doc:
180 | // act:
181 | rule #Jug.base => 4
182 | ```
183 |
184 | ### Drip
185 |
186 | ```k
187 | syntax Int ::= "#Drip.wards" "[" Int "]" [function]
188 | // -----------------------------------------------
189 | // doc: whether `$0` is an owner of `Drip`
190 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
191 | rule #Drip.wards[A] => #hashedLocation("Solidity", 0, A)
192 |
193 | syntax Int ::= "#Drip.ilks" "[" Int "].tax" [function]
194 | // ----------------------------------------------------
195 | // doc: stability fee of `$0`
196 | // act: `$0` has stability fee `.`
197 | rule #Drip.ilks[Ilk].tax => #hashedLocation("Solidity", 1, Ilk) +Int 0
198 |
199 | syntax Int ::= "#Drip.ilks" "[" Int "].rho" [function]
200 | // ----------------------------------------------------
201 | // doc: last drip time of `$0`
202 | // act: `$0` was dripped at `.`
203 | rule #Drip.ilks[Ilk].rho => #hashedLocation("Solidity", 1, Ilk) +Int 1
204 |
205 | syntax Int ::= "#Drip.vat" [function]
206 | // ----------------------------------
207 | // doc: `Vat` that this `Drip` points to
208 | // act: this Drip points to Vat `.`
209 | rule #Drip.vat => 2
210 |
211 | syntax Int ::= "#Drip.vow" [function]
212 | // ----------------------------------
213 | // doc: `Vow` that this `Drip` points to
214 | // act: this Drip points to Vow `.`
215 | rule #Drip.vow => 3
216 |
217 | syntax Int ::= "#Drip.repo" [function]
218 | // -----------------------------------
219 | // doc: base interest rate
220 | // act: the base interest rate is `.`
221 | rule #Drip.repo => 4
222 | ```
223 |
224 | ### Vow
225 |
226 | ```k
227 | syntax Int ::= "#Vow.wards" "[" Int "]" [function]
228 | // ---------------------------------
229 | // doc: whether `$0` is an owner of `Vow`
230 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
231 | rule #Vow.wards[A] => #hashedLocation("Solidity", 0, A)
232 |
233 | syntax Int ::= "#Vow.vat" [function]
234 | // ---------------------------------
235 | // doc: `Vat` that this `Vow` points to
236 | // act: this Vow points to Vat `.`
237 | rule #Vow.vat => 1
238 |
239 | syntax Int ::= "#Vow.flapper" [function]
240 | // ---------------------------------
241 | // doc: `Flapper` that this `Vow` points to
242 | // act: this Vow points to Flapper `.`
243 | rule #Vow.flapper => 2
244 |
245 | syntax Int ::= "#Vow.flopper" [function]
246 | // ---------------------------------
247 | // doc: `Flopper` that this `Vow` points to
248 | // act: this Vow points to Flopper `.`
249 | rule #Vow.flopper => 3
250 |
251 | syntax Int ::= "#Vow.sin" "[" Int "]" [function]
252 | // ---------------------------------------------
253 | // doc: sin queued at timestamp `$0`
254 | // act: `.` sin queued at timestamp `$0`
255 | rule #Vow.sin[A] => #hashedLocation("Solidity", 4, A)
256 |
257 | syntax Int ::= "#Vow.Sin" [function]
258 | // ---------------------------------
259 | // doc: total queued sin
260 | // act: the total queued sin is `.`
261 | rule #Vow.Sin => 5
262 |
263 | syntax Int ::= "#Vow.Ash" [function]
264 | // ---------------------------------
265 | // doc: total sin in debt auctions
266 | // act: the total sin in debt auctions is `.`
267 | rule #Vow.Ash => 6
268 |
269 | syntax Int ::= "#Vow.wait" [function]
270 | // ----------------------------------
271 | // doc: sin maturation time
272 | // act: the sin maturation time is `.`
273 | rule #Vow.wait => 7
274 |
275 | syntax Int ::= "#Vow.sump" [function]
276 | // ----------------------------------
277 | // doc: debt auction lot size
278 | // act: the debt auction lot size is `.`
279 | rule #Vow.sump => 8
280 |
281 | syntax Int ::= "#Vow.bump" [function]
282 | // ----------------------------------
283 | // doc: surplus auction lot size
284 | // act: the surplus auction lot size is `.`
285 | rule #Vow.bump => 9
286 |
287 | syntax Int ::= "#Vow.hump" [function]
288 | // ---------------------------------
289 | // doc: surplus dai cushion
290 | // act: the surplus dai cushion is `.`
291 | rule #Vow.hump => 10
292 |
293 | syntax Int ::= "#Vow.live" [function]
294 | // ---------------------------------
295 | // doc: liveness flag
296 | // act: the system is active/inactive `.`
297 | rule #Vow.live => 11
298 |
299 | ```
300 |
301 | ### Cat
302 |
303 | ```k
304 | syntax Int ::= "#Cat.wards" "[" Int "]" [function]
305 | // ---------------------------------
306 | // doc: whether `$0` is an owner of `Cat`
307 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
308 | rule #Cat.wards[A] => #hashedLocation("Solidity", 0, A)
309 |
310 | syntax Int ::= "#Cat.ilks" "[" Int "].flip" [function]
311 | // ---------------------------------------------------
312 | // doc: `Flipper` for `$0`
313 | // act:
314 | rule #Cat.ilks[Ilk].flip => #hashedLocation("Solidity", 1, Ilk) +Int 0
315 |
316 | syntax Int ::= "#Cat.ilks" "[" Int "].chop" [function]
317 | // ---------------------------------------------------
318 | // doc: liquidation penalty for `$0`
319 | // act:
320 | rule #Cat.ilks[Ilk].chop => #hashedLocation("Solidity", 1, Ilk) +Int 1
321 |
322 | syntax Int ::= "#Cat.ilks" "[" Int "].lump" [function]
323 | // ---------------------------------------------------
324 | // doc: liquidation lot size for `$0`
325 | // act:
326 | rule #Cat.ilks[Ilk].lump => #hashedLocation("Solidity", 1, Ilk) +Int 2
327 |
328 | syntax Int ::= "#Cat.live" [function]
329 | // ----------------------------------
330 | // doc: system liveness
331 | // act:
332 | rule #Cat.live => 2
333 |
334 | syntax Int ::= "#Cat.vat" [function]
335 | // ---------------------------------
336 | // doc: `Vat` that this `Cat` points to
337 | // act:
338 | rule #Cat.vat => 3
339 |
340 | syntax Int ::= "#Cat.vow" [function]
341 | // ---------------------------------
342 | // doc: `Vow` that this `Cat` points to
343 | // act:
344 | rule #Cat.vow => 4
345 | ```
346 |
347 | ### GemJoin
348 |
349 | ```k
350 | syntax Int ::= "#GemJoin.vat" [function]
351 | // -------------------------------------
352 | // doc: `Vat` that this adapter points to
353 | // act:
354 | rule #GemJoin.vat => 0
355 |
356 | syntax Int ::= "#GemJoin.ilk" [function]
357 | // -------------------------------------
358 | // doc: collateral type of this adapter
359 | // act:
360 | rule #GemJoin.ilk => 1
361 |
362 | syntax Int ::= "#GemJoin.gem" [function]
363 | // -------------------------------------
364 | // doc: underlying token of this adapter
365 | // act:
366 | rule #GemJoin.gem => 2
367 | ```
368 |
369 | ### DaiJoin
370 |
371 | ```k
372 | syntax Int ::= "#DaiJoin.vat" [function]
373 | // -------------------------------------
374 | // doc: `Vat` that this adapter points to
375 | // act:
376 | rule #DaiJoin.vat => 0
377 |
378 | syntax Int ::= "#DaiJoin.dai" [function]
379 | // -------------------------------------
380 | // doc: underlying dai token of this adapter
381 | // act:
382 | rule #DaiJoin.dai => 1
383 | ```
384 |
385 | ### Flip
386 |
387 | ```k
388 | syntax Int ::= "#Flipper.wards" "[" Int "]" [function]
389 | // ---------------------------------------
390 | // doc: whether `$0` is an owner of `Flip`
391 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
392 | rule #Flipper.wards[A] => #hashedLocation("Solidity", 0, A)
393 |
394 | syntax Int ::= "#Flipper.bids" "[" Int "].bid" [function]
395 | // ------------------------------------------------------
396 | // doc: current bid (dai)
397 | // act:
398 | rule #Flipper.bids[N].bid => #hashedLocation("Solidity", 1, N) +Int 0
399 |
400 | syntax Int ::= "#Flipper.bids" "[" Int "].lot" [function]
401 | // ------------------------------------------------------
402 | // doc: current lot (gem)
403 | // act:
404 | rule #Flipper.bids[N].lot => #hashedLocation("Solidity", 1, N) +Int 1
405 |
406 | // packed, use #WordPackAddrUInt48UInt48 to unpack this
407 | syntax Int ::= "#Flipper.bids" "[" Int "].guy_tic_end" [function]
408 | // --------------------------------------------------------------
409 | // doc:
410 | // act:
411 | rule #Flipper.bids[N].guy_tic_end => #hashedLocation("Solidity", 1, N) +Int 2
412 |
413 | syntax Int ::= "#Flipper.bids" "[" Int "].usr" [function]
414 | // ------------------------------------------------------
415 | // doc: CDP owner
416 | // act:
417 | rule #Flipper.bids[N].usr => #hashedLocation("Solidity", 1, N) +Int 3
418 |
419 | syntax Int ::= "#Flipper.bids" "[" Int "].gal" [function]
420 | // ------------------------------------------------------
421 | // doc: beneficiary of the auction
422 | // act:
423 | rule #Flipper.bids[N].gal => #hashedLocation("Solidity", 1, N) +Int 4
424 |
425 | syntax Int ::= "#Flipper.bids" "[" Int "].tab" [function]
426 | // ------------------------------------------------------
427 | // doc: beneficiary of the auction
428 | // act:
429 | rule #Flipper.bids[N].tab => #hashedLocation("Solidity", 1, N) +Int 5
430 |
431 | syntax Int ::= "#Flipper.vat" [function]
432 | // ---------------------------------------
433 | // doc: CDP engine
434 | // act:
435 | rule #Flipper.vat => 2
436 |
437 | syntax Int ::= "#Flipper.ilk" [function]
438 | // ---------------------------------------
439 | // doc: collateral type
440 | // act:
441 | rule #Flipper.ilk => 3
442 |
443 | syntax Int ::= "#Flipper.beg" [function]
444 | // ---------------------------------------
445 | // doc: minimum bid increment
446 | // act:
447 | rule #Flipper.beg => 4
448 |
449 | // packed, use #WordPackUInt48UInt48 to unpack this
450 | syntax Int ::= "#Flipper.ttl_tau" [function]
451 | // -----------------------------------------
452 | // doc:
453 | // act:
454 | rule #Flipper.ttl_tau => 5
455 |
456 | syntax Int ::= "#Flipper.kicks" [function]
457 | // ---------------------------------------
458 | // doc: auction counter
459 | // act:
460 | rule #Flipper.kicks => 6
461 | ```
462 |
463 |
464 | ### Flop
465 |
466 | ```k
467 | syntax Int ::= "#Flopper.wards" "[" Int "]" [function]
468 | // ---------------------------------------
469 | // doc: whether `$0` is an owner of `Flop`
470 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
471 | rule #Flopper.wards[A] => #hashedLocation("Solidity", 0, A)
472 |
473 | syntax Int ::= "#Flopper.bids" "[" Int "].bid" [function]
474 | // ------------------------------------------------------
475 | // doc: current bid (dai)
476 | // act:
477 | rule #Flopper.bids[N].bid => #hashedLocation("Solidity", 1, N) +Int 0
478 |
479 | syntax Int ::= "#Flopper.bids" "[" Int "].lot" [function]
480 | // ------------------------------------------------------
481 | // doc: current lot (gem)
482 | // act:
483 | rule #Flopper.bids[N].lot => #hashedLocation("Solidity", 1, N) +Int 1
484 |
485 | // packed, use #WordPackAddrUInt48UInt48 to unpack this
486 | syntax Int ::= "#Flopper.bids" "[" Int "].guy_tic_end" [function]
487 | // --------------------------------------------------------------
488 | // doc:
489 | // act:
490 | rule #Flopper.bids[N].guy_tic_end => #hashedLocation("Solidity", 1, N) +Int 2
491 |
492 | syntax Int ::= "#Flopper.vat" [function]
493 | // ---------------------------------------
494 | // doc: dai token
495 | // act:
496 | rule #Flopper.vat => 2
497 |
498 | syntax Int ::= "#Flopper.gem" [function]
499 | // ---------------------------------------
500 | // doc: mkr token
501 | // act:
502 | rule #Flopper.gem => 3
503 |
504 | syntax Int ::= "#Flopper.beg" [function]
505 | // ---------------------------------------
506 | // doc: minimum bid increment
507 | // act:
508 | rule #Flopper.beg => 4
509 |
510 | // packed, use #WordPackUInt48UInt48 to unpack this
511 | syntax Int ::= "#Flopper.ttl_tau" [function]
512 | // -----------------------------------------
513 | // doc:
514 | // act:
515 | rule #Flopper.ttl_tau => 5
516 |
517 | syntax Int ::= "#Flopper.kicks" [function]
518 | // ---------------------------------------
519 | // doc: auction counter
520 | // act:
521 | rule #Flopper.kicks => 6
522 |
523 | syntax Int ::= "#Flopper.live" [function]
524 | // ---------------------------------------
525 | // doc: liveness flag
526 | // act:
527 | rule #Flopper.live => 7
528 | ```
529 |
530 | ### Flap
531 |
532 | ```k
533 | syntax Int ::= "#Flapper.wards" "[" Int "]" [function]
534 | // ---------------------------------------
535 | // doc: whether `$0` is an owner of `Flop`
536 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
537 | rule #Flapper.wards[A] => #hashedLocation("Solidity", 0, A)
538 |
539 | syntax Int ::= "#Flapper.bids" "[" Int "].bid" [function]
540 | // ------------------------------------------------------
541 | // doc: current bid (dai)
542 | // act:
543 | rule #Flapper.bids[N].bid => #hashedLocation("Solidity", 1, N) +Int 0
544 |
545 | syntax Int ::= "#Flapper.bids" "[" Int "].lot" [function]
546 | // ------------------------------------------------------
547 | // doc: current lot (gem)
548 | // act:
549 | rule #Flapper.bids[N].lot => #hashedLocation("Solidity", 1, N) +Int 1
550 |
551 | // packed, use #WordPackAddrUInt48UInt48 to unpack this
552 | syntax Int ::= "#Flapper.bids" "[" Int "].guy_tic_end" [function]
553 | // --------------------------------------------------------------
554 | // doc:
555 | // act:
556 | rule #Flapper.bids[N].guy_tic_end => #hashedLocation("Solidity", 1, N) +Int 2
557 |
558 | syntax Int ::= "#Flapper.vat" [function]
559 | // ---------------------------------------
560 | // doc: dai token
561 | // act:
562 | rule #Flapper.vat => 2
563 |
564 | syntax Int ::= "#Flapper.gem" [function]
565 | // ---------------------------------------
566 | // doc: mkr token
567 | // act:
568 | rule #Flapper.gem => 3
569 |
570 | syntax Int ::= "#Flapper.beg" [function]
571 | // ---------------------------------------
572 | // doc: minimum bid increment
573 | // act:
574 | rule #Flapper.beg => 4
575 |
576 | // packed, use #WordPackUInt48UInt48 to unpack this
577 | syntax Int ::= "#Flapper.ttl_tau" [function]
578 | // -----------------------------------------
579 | // doc:
580 | // act:
581 | rule #Flapper.ttl_tau => 5
582 |
583 | syntax Int ::= "#Flapper.kicks" [function]
584 | // ---------------------------------------
585 | // doc: auction counter
586 | // act:
587 | rule #Flapper.kicks => 6
588 |
589 | syntax Int ::= "#Flapper.live" [function]
590 | // ---------------------------------------
591 | // doc: liveness flag
592 | // act:
593 | rule #Flapper.live => 7
594 | ```
595 |
596 | ### GemLike
597 |
598 | A hypothetical token contract, based on `ds-token`:
599 |
600 | ```k
601 | syntax Int ::= "#Gem.balances" "[" Int "]" [function]
602 | // --------------------------------------------------
603 | // doc: `gem` balance of `$0`
604 | // act:
605 | rule #Gem.balances[A] => #hashedLocation("Solidity", 3, A)
606 |
607 | syntax Int ::= "#Gem.stopped" [function]
608 | // --------------------------------------------------
609 | // doc: `gem` balance of `$0`
610 | // act:
611 | rule #Gem.stopped => 4
612 |
613 | syntax Int ::= "#Gem.allowance" "[" Int "][" Int "]" [function]
614 | // -----------------------------------------------
615 | // doc: the amount that can be spent on someones behalf
616 | // act: `$1 can spend `.` tokens belonging to `$0`
617 | rule #Gem.allowance[A][B] => #hashedLocation("Solidity", 8, A B)
618 | ```
619 |
620 | ### End
621 |
622 | ```k
623 | // act: public
624 | syntax Int ::= "#End.wards" "[" Int "]" [function]
625 | // -----------------------------------------------
626 | // doc: whether `$0` is an owner of `End`
627 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
628 | rule #End.wards[A] => #hashedLocation("Solidity", 0, A)
629 |
630 | syntax Int ::= "#End.vat" [function]
631 | // ---------------------------------
632 | // doc: `Vat` that this `End` points to
633 | // act:
634 | rule #End.vat => 1
635 |
636 | syntax Int ::= "#End.cat" [function]
637 | // ---------------------------------
638 | // doc: `cat` that this `End` points to
639 | // act:
640 | rule #End.cat => 2
641 |
642 | syntax Int ::= "#End.vow" [function]
643 | // ---------------------------------
644 | // doc: `Vow` that this `End` points to
645 | // act:
646 | rule #End.vow => 3
647 |
648 | syntax Int ::= "#End.spot" [function]
649 | // ---------------------------------
650 | // doc: `Spot` that this `End` points to
651 | // act:
652 | rule #End.spot => 4
653 |
654 | syntax Int ::= "#End.live" [function]
655 | // ----------------------------------
656 | // doc: system liveness
657 | // act:
658 | rule #End.live => 5
659 |
660 | syntax Int ::= "#End.when" [function]
661 | // ----------------------------------
662 | // doc: time of cage
663 | // act:
664 | rule #End.when => 6
665 |
666 | syntax Int ::= "#End.wait" [function]
667 | // ----------------------------------
668 | // doc: processing period
669 | // act:
670 | rule #End.wait => 7
671 |
672 | syntax Int ::= "#End.debt" [function]
673 | // ----------------------------------
674 | // doc: total outstanding debt following processing
675 | // act:
676 | rule #End.debt => 8
677 |
678 | syntax Int ::= "#End.tag" "[" Int "]" [function]
679 | // -----------------------------------------------
680 | // doc: the cage price of ilk `$0`
681 | // act:
682 | rule #End.tag[Ilk] => #hashedLocation("Solidity", 9, Ilk)
683 |
684 | syntax Int ::= "#End.gap" "[" Int "]" [function]
685 | // -----------------------------------------------
686 | // doc: the collateral shortfall of ilk `$0`
687 | // act:
688 | rule #End.gap[Ilk] => #hashedLocation("Solidity", 10, Ilk)
689 |
690 | syntax Int ::= "#End.Art" "[" Int "]" [function]
691 | // -----------------------------------------------
692 | // doc: the total debt of ilk `$0`
693 | // act:
694 | rule #End.Art[Ilk] => #hashedLocation("Solidity", 11, Ilk)
695 |
696 | syntax Int ::= "#End.fix" "[" Int "]" [function]
697 | // -----------------------------------------------
698 | // doc: the final cash price of ilk `$0`
699 | // act:
700 | rule #End.fix[Ilk] => #hashedLocation("Solidity", 12, Ilk)
701 |
702 | syntax Int ::= "#End.bag" "[" Int "]" [function]
703 | // -----------------------------------------------
704 | // doc: the packed dai of user `$0`
705 | // act:
706 | rule #End.bag[Usr] => #hashedLocation("Solidity", 13, Usr)
707 |
708 | syntax Int ::= "#End.out" "[" Int "][" Int "]" [function]
709 | // ---------------------------------------------
710 | // doc: cashed collateral of ilk `$0` assigned to `$1`
711 | // act:
712 | rule #End.out[Ilk][Usr] => #hashedLocation("Solidity", 14, Ilk Usr)
713 | ```
714 |
715 | ### Pot
716 |
717 | ```k
718 | syntax Int ::= "#Pot.wards" "[" Int "]" [function]
719 | // -----------------------------------------------
720 | // doc: whether `$0` is an owner of `Pot`
721 | // act: address `$0` is `. == 1 ? authorised : unauthorised`
722 | rule #Pot.wards[A] => #hashedLocation("Solidity", 0, A)
723 |
724 | syntax Int ::= "#Pot.pie" "[" Int "]" [function]
725 | // ----------------------------------------------------
726 | // doc: balance that `$0` has locked in this pot
727 | // act:
728 | rule #Pot.pie[Usr] => #hashedLocation("Solidity", 1, Usr)
729 |
730 | syntax Int ::= "#Pot.Pie" [function]
731 | // ----------------------------------
732 | // doc: total amount of dai locked in this `Pot`
733 | // act: this Pot points to Vat `.`
734 | rule #Pot.Pie => 2
735 |
736 | syntax Int ::= "#Pot.dsr" [function]
737 | // ----------------------------------
738 | // doc: the current deposit interest rate of this `Pot`
739 | // act:
740 | rule #Pot.dsr => 3
741 |
742 | syntax Int ::= "#Pot.chi" [function]
743 | // ----------------------------------
744 | // doc: `Vat` that this `Pot` points to
745 | // act: this Pot points to Vat `.`
746 | rule #Pot.chi => 4
747 |
748 | syntax Int ::= "#Pot.vat" [function]
749 | // ----------------------------------
750 | // doc: `Vat` that this `Pot` points to
751 | // act: this Pot points to Vat `.`
752 | rule #Pot.vat => 5
753 |
754 | syntax Int ::= "#Pot.vow" [function]
755 | // ----------------------------------
756 | // doc: `Vow` that this `Pot` points to
757 | // act: this Pot points to Vow `.`
758 | rule #Pot.vow => 6
759 |
760 | syntax Int ::= "#Pot.rho" [function]
761 | // ----------------------------------
762 | // doc:
763 | // act:
764 | rule #Pot.rho => 7
765 | ```
766 | ### DSToken
767 |
768 | ```k
769 | syntax Int ::= "#DSToken.supply" [function]
770 | rule #DSToken.supply => 0
771 |
772 | syntax Int ::= "#DSToken.balances" "[" Int "]" [function]
773 | rule #DSToken.balances[A] => #hashedLocation("Solidity", 1, A)
774 |
775 | syntax Int ::= "#DSToken.allowance" "[" Int "][" Int "]" [function]
776 | rule #DSToken.allowance[A][B] => #hashedLocation("Solidity", 2, A B)
777 |
778 | syntax Int ::= "#DSToken.authority" [function]
779 | rule #DSToken.authority => 3
780 |
781 | syntax Int ::= "#DSToken.owner_stopped" [function]
782 | rule #DSToken.owner_stopped => 4
783 |
784 | syntax Int ::= "#DSToken.symbol" [function]
785 | rule #DSToken.symbol => 5
786 |
787 | syntax Int ::= "#DSToken.decimals" [function]
788 | rule #DSToken.decimals => 6
789 | ```
790 |
791 | ### DSValue
792 |
793 | ```k
794 | syntax Int ::= "#DSValue.authority" [function]
795 | rule #DSValue.authority => 0
796 |
797 | syntax Int ::= "#DSValue.owner_has" [function]
798 | rule #DSValue.owner_has => 1
799 |
800 | syntax Int ::= "#DSValue.val" [function]
801 | rule #DSValue.val => 2
802 |
803 | ```
804 |
805 | ### Spotter
806 |
807 | ```act
808 | syntax Int ::= "#Spotter.wards" "[" Int "]" [function]
809 | rule #Spotter.wards[A] => #hashedLocation("Solidity", 0, A)
810 |
811 | syntax Int ::= "#Spotter.ilks" "[" Int "].pip" [function]
812 | rule #Spotter.ilks[Ilk].pip => #hashedLocation("Solidity", 1, Ilk) +Int 0
813 |
814 | syntax Int ::= "#Spotter.ilks" "[" Int "].mat" [function]
815 | rule #Spotter.ilks[Ilk].mat => #hashedLocation("Solidity", 1, Ilk) +Int 1
816 |
817 | syntax Int ::= "#Spotter.vat" [function]
818 | rule #Spotter.vat => 2
819 |
820 | syntax Int ::= "#Spotter.par" [function]
821 | rule #Spotter.par => 3
822 | ```
823 |
--------------------------------------------------------------------------------