---
title: "5.10 Recap and reference"
url: https://una-lang.org/en/learn/contracts/recap-and-reference/
release: v0.4.0
edition: "0.2"
---

# 5.10 Recap and reference

## 5.10.1 For agents

:::agents
`una --json check .` gives each obligation that is not proven as a diagnostic with its `obligation` (id, kind, goal, status) and its `counterexample` as name and value pairs. For [a coupon that can be worth more than the order](https://una-lang.org/en/learn/contracts/common-mistakes/#a-coupon-that-can-be-worth-more-than-the-order-u5001):

```json include="mistakes/1/expected/commands/json.txt#L2"
{"schema":"una.diagnostics/1","diagnostics":[{"schema":"una.diagnostic/1","code":"U5001","severity":"error","domain":"verification","message":"postcondition of `discount` is refuted","primary":{"file":"src/billing.una","start":{"line":64,"col":25},"end":{"line":64,"col":28}},"related":[{"file":"src/billing.una","start":{"line":58,"col":11},"end":{"line":58,"col":27},"message":"ensures clause"}],"obligation":{"id":"ob-e0a2abc0bb6a","kind":"postcondition","goal":"result <= amount","status":"refuted"},"counterexample":{"bindings":[{"name":"amount","value":0},{"name":"coupon","value":"CentsOff"},{"name":"coupon.amount","value":1},{"name":"coupon.rate","value":101},{"name":"result","value":1}]},"repairs":[{"rank":1,"escape_cost":0,"description":"add a guard or an arm so that the failing path returns a value for which `result <= amount` holds","edit":null},{"rank":2,"escape_cost":0,"description":"adjust the `ensures` clause","edit":null}],"explain":"una explain U5001"}],"fixable":0}
```

The repairs of U5001 and U5002 carry no `edit`, since only the author knows whether the code or the contract is wrong, so `una fix` leaves them. `una --json obligations .` and `una --json trace <ID>` list every obligation, proven or not. The compact rule: *every call proves the callee's `requires`, every return proves the `ensures`, every value that enters a refined kind proves its condition, and unknown is an error; clauses multiply and divide only by literals.*
:::

## 5.10.2 Recap

:::recap
- `requires` is what a caller must prove; `ensures` is what every return promises. Callers know a function by its header alone.
- A counterexample shows where a contract breaks. Fix the code or the contract, and keep a real case as an example.
- Put a rule that holds of every value on its kind, `Int where it >= 0`, and name a shared rule with a `reflect` predicate.
- Clauses multiply and divide only by literals. For a product of two values, bind it with `let` and guard it.
- `una obligations .` lists every question and its status. U5001 is refuted, U5002 unknown; both are errors.
- Record business rules as requirements, tie functions to them with `derived from`, and follow them with `una trace`.
:::

## 5.10.3 Reference

:::reference
- Construct pages: [`requires`](https://una-lang.org/en/docs/language/functions/requires/), [`ensures`](https://una-lang.org/en/docs/language/functions/ensures/), [`where` and refinements](https://una-lang.org/en/docs/language/types/where/), [`predicate`](https://una-lang.org/en/docs/language/types/predicate/), [`kind`](https://una-lang.org/en/docs/language/types/kind/), [`requirement`](https://una-lang.org/en/docs/language/requirements/requirement/), [`example`](https://una-lang.org/en/docs/language/examples/example/), [verification](https://una-lang.org/en/docs/language/verification/)
- Prelude: [`Nat`, `min`](https://una-lang.org/en/docs/std/)
- Commands: [`una check`](https://una-lang.org/en/docs/cli/check/), [`una obligations`](https://una-lang.org/en/docs/cli/obligations/), [`una trace`](https://una-lang.org/en/docs/cli/trace/), [`una report`](https://una-lang.org/en/docs/cli/report/)
- Diagnostics: [U1001](https://una-lang.org/en/docs/errors/U1001/), [U1002](https://una-lang.org/en/docs/errors/U1002/) (a name declared twice), [U1005](https://una-lang.org/en/docs/errors/U1005/) (a requirement identifier of the wrong form), [U1006](https://una-lang.org/en/docs/errors/U1006/), [U1007](https://una-lang.org/en/docs/errors/U1007/), [U2002](https://una-lang.org/en/docs/errors/U2002/), [U2012](https://una-lang.org/en/docs/errors/U2012/) (`result` outside `ensures`), [U2014](https://una-lang.org/en/docs/errors/U2014/), [U2015](https://una-lang.org/en/docs/errors/U2015/) (a predicate body that is not allowed), [U5001](https://una-lang.org/en/docs/errors/U5001/), [U5002](https://una-lang.org/en/docs/errors/U5002/), [U5003](https://una-lang.org/en/docs/errors/U5003/) (the solver is missing or not the pinned version)
- Specification: [functions and contracts](https://una-lang.org/en/docs/spec/04-functions-and-contracts/), [types](https://una-lang.org/en/docs/spec/03-types/), [verification](https://una-lang.org/en/docs/spec/12-verification/), [requirements and examples](https://una-lang.org/en/docs/spec/08-requirements-and-examples/)
:::
