What is the meaning of an assumption in scala compared to an assertion?

后端 未结 3 577
悲哀的现实
悲哀的现实 2021-01-31 07:44

Scala seems to define 3 kinds of assertions: assert, require and assume.

As far as I can understand, the difference (compared to a

3条回答
  •  再見小時候
    2021-01-31 08:35

    I second Adams answer, here are just some small additions:

    When assume is violated, the verification tool silently prunes the path, i.e. does not follow the path any deeper.

    Hence assume is often used to formulate pre-conditions, assert to formulate post-conditions.

    These concepts are used by many tools, e.g. the concolic testing tool KLEE, software bounded model checking tools like CBMC and LLBMC, and partly also by static code analysis tools based on abstract interpretation. The article Finding common ground: Choose, Assert, Assume introduces these concepts and tries to standardize them.

提交回复
热议问题