Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 1 edits #26

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Chapter 1 edits #26

wants to merge 18 commits into from

Conversation

gottschali
Copy link
Collaborator

No description provided.

- use a similar version for slices and arrays
  (could be confusing otherwise what kind of binary search we are
  talking about)
- i omitted the ghost idx
  - unfortunately we then only have the found ==> ... case
- updated overflow and termination section which refer to this example

Another option would be to move the binary section after
introducing ghost and pure,
as a separate "case study".
Then the loop section would need some other example that is explained more.
people might be already familiar with the BinarySearch function from the
slice package in Go's standard library.
Returning found and index also allows us to write postconditions for
both cases (element contained / not contained)

changed sections that refer to this example
- add note about triggers
  - added empty page for the advanced section
- introduce implication together
  do not really have a meaningful `forall` example without arrays, and
  the need to contrains indices.
  Of course, one could show mathematical things like `forall i int ::
- i * i >= 0` but then we would neglect overflow again
- example for existential quantifier
  tried to explain why we should not use them
  can complete the example in the loop section
example with a linear search
now showing both found/not found cases

might have small overlap with binary search section

show the errors not established / preserved with very trivial mistakes

also important: invariants must not hold when exiting abnormally (e.g.
break or return) and only after an iteration
better to reuse the already familiar example
than to introduce a new example.

`almostMax` anyways bad with only the postcondition res >= arr[i]
Otherwise would also return an index (possibly ghost?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant