Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions content/docs/automation/iris_goals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "The anatomy of an Iris goal"
tags:
- learn
- iris
requires: []
provides:
- iris_goals
eleventyNavigation:
order: 202
parent: learn
---

Both the IPM tactics and the `sep` family of tactics work on Iris goals such as the following:

```rocq
n, m : Z
H : n + 1 = m
--------------------------------------
"HP2" : P2
_ : P1
--------------------------------------□
"HQ1" : Q1
_ : Q2
--------------------------------------∗
R
```

Here, we must prove `R` assuming `P1`, `P2`, `Q1` and `Q2`.
Assumption `P1` and `P2` can be duplicated or discarded
freely, unlike `Q1` and `Q2`: We say `P1` and `P2` are intuitionistic and form
the intuitionistic context, while `Q1` and `Q2` form the spatial context.

Iris assumptions can be named or anonymous. Tactics can use names to act on
specific hypotheses, but otherwise names are not meaningful.

Sometimes, we might refer to these goals as `Γ ; Γp ; Γs ⊢ Q`, where `Γ` is the
Rocq context, `Γp` is the intuitionistic context, `Γs` is the spatial context,
and `Q` is the conclusion.

A plain Iris entailment `P ⊢ Q` can be converted via `iStartProof` to the following Iris goal

```rocq
--------------------------------------∗
P -∗ Q
```
10 changes: 10 additions & 0 deletions content/docs/automation/sep.11tydata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Inside the `sep` Tactic"
tags:
- learn
requires: []
provides:
- automation
eleventyNavigation:
order: 201
parent: learn
10 changes: 10 additions & 0 deletions content/docs/automation/sep_old.11tydata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Inside the `sep` Tactic"
tags:
- learn
requires: []
provides:
- automation
eleventyNavigation:
order: 201
parent: learn
184 changes: 184 additions & 0 deletions content/docs/automation/sep_old.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
(*|
In this section, we explain the semantics of our core automation tactics: `sep`,
and its wrappers like `work` and `go`.

`sep` simplifies or solves separation logic entailments `P ⊢ Q` via builtin
proof rules and user-defined Rocq hints.

1. apply introduction rules for universals and wands

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. apply introduction rules for universals and wands
The core algorithm repeats these steps:
1. apply introduction rules for universals and wands

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Need to add mentions of naming policies).

2. then apply forward and backward hints to simplify assumptions and

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the priorities for \bwd and \fwd different?

We're confused about an hint like this, but I plan to not explain it — but figure it out so the explanation isn't false.

#[program]
Definition type_ptrR_to_type_ptr_FB p ty :=
  \fwd
  \proving p |-> type_ptrR ty (* spatial conclusion to match *)
  \through type_ptr ty p (* replacement spatial conclusion *)
  \end.

conclusions, as far as possible

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
conclusions, as far as possible
conclusions, as far as possible; hints are applied in order

3. then apply learning hints to instantiate any existentials as far as possible
4. if enabled, instantiate any remaining existential quantifiers with evars

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be at the very end; ework will only do that if there is nothing else it can do.

5. apply introduction rules for joint conjunctions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gregory asked what this means, I answered iSplit — maybe

Suggested change
5. apply introduction rules for joint conjunctions
5. apply introduction rules for joint conjunctions (like `iSplit`)

<!-- when? this seems the most reasonable point -->
6. then apply framing/identity cancellation, and cancellation hints as far as possible

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identity cancellation is at a fixed cost (hopefully higher than most hints users write). Is this list the wrong place to announce that priorities/costs matter?

7. restart from 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe talk about priorities rather than bwd/fwd as a separate step?

The actual implementation has separate phases — but this should not matter because hints should be "confluent" — concretely,

  • idiomatic cancelx hints will introduce terms in "bwd/fwd normal form" not possible, because normal forms are not preserved by instantiating hint metavariables
  • idiomatic cancelx hints should only be triggered on conjuncts in normal forms — which is easier, so if you introduce a non-normal form (and phase ordering questions apply) no cancelx hints will apply on it, so that'll be processed by the next bwd phase. This way, phases aren't exposed to the user.
  • also, bwd/fwd hints shouldn't be "orphans" morally


The process terminates when no progress is possible or when the goal is solved.

# A quick tour

## Iris goals

`sep` works on Iris goals `Γ ; Γp ; Γs ⊢ Q`, where `Γ` is the Rocq context,

@pgiarrusso-sl pgiarrusso-sl May 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Needed: show how Γ ; Γp ; Γs ⊢ Q actually looks in Rocq.
  • Possible: use actual goals instead of this notation. (But they seem unwieldy).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sep technically also works on plain bi entailments; not sure if this is relevant here (and you do not claim that it doesn't)

`Γp` is the intuitionistic context, `Γs` is the spatial context, and `Q` is the
conclusion.
In an Iris goal, assumptions in `Γp` can be duplicated or discarded

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull this section out into a separate section on "Iris goals" .

Also explain difference between pure and Iris assertions. (Is that a separate section).

@pgiarrusso-sl pgiarrusso-sl May 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also point out the existence of evars. (But users know them, and maybe the user of evars is an extension since we avoid ego).

freely, unlike assumptions in `Γs`.
Comment on lines +22 to +28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose moving this out to a separate page.

Plain entailments are converted to Iris goals automatically, as if by
`iStartProof`.

Iris assumptions can be named or anonymous; by default `sep` will preserve named
assumptions unchanged, but `$usenamed=true` will override this behavior.

@pgiarrusso-sl pgiarrusso-sl May 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Idiomatic IPM proofs name hypotheses, but idiomatic work proofs do not, and we prefer avoiding splitting the context".

See also next section, but we don't just avoid iSplitL.

  1. we prefer to never split the goal eagerly (usually, work in a single goal) — avoid splitting context with iSplitL — avoid splitting context with iApply with multiple premises. "We avoid doing frame inference"...
  2. idiomatically we avoid name management for assumptions
  3. avoid introducing existentials


<!-- to move -->
`sep` will eliminate existentials and conjunctions in assumptions when possible.
That includes separating conjunctions in the spatial context, conjunctions in
the intuitionistic context, and separation conjunctions in the intuitionistic
context if the bi in use is `BiPositive`.

`sep` bubbles up existentials to the top of the conclusion (but will not treat
this as progress, i.e. the bubbling up is not committed unless actual progress
is made in another fashion).

## Proof strategy

While manual proofs can introduce separating conjunctions by splitting the
context, `sep` does not attempt that, because that requires guessing how to
split the context correctly.

Instead, we can cancel spatial assumptions against conclusion conjuncts using
the following cancellation rule:
```
P1 ⊢~ P2 Γ ; Γp ; Γs ⊢ Q

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably go back to identity cancellation here.

Gregory suggests leaving the "other steps" (the hints) to other documents (about bwd/fwd etc), so we don't need to talk much about the generalization here.

-------------------------------------- CANCEL
Γ ; Γp ; P1, Γs ⊢ P2 ∗ Q
```
Comment on lines +51 to +57

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Instead, we can cancel spatial assumptions against conclusion conjuncts using
the following cancellation rule:
```
P1~ P2 Γ ; Γp ; Γs ⊢ Q
-------------------------------------- CANCEL
Γ ; Γp ; P1, Γs ⊢ P2 ∗ Q
```
The core automation applies "rules" eagerly based on priorities.
Instead, we can cancel spatial assumptions against conclusion conjuncts using
the following cancellation rule:

P1 ⊢~ P2 Γ ; Γp ; Γs ⊢ Q
-------------------------------------- CANCEL
Γ ; Γp ; P1, Γs ⊢ P2 ∗ Q


bwd.md

Applying a BWD rules replace a (separation) conjunction in the goal with another:

Definition my_hint :=
  \bwd
  \proving A
  \through B
  \end.
Next Obligation. .. Qed.

When applying this rule on a goal of the form

...
---------------*
exists a b c, A ** X ** ...

will result in a goal of the form

...
--------------*
exists a b c, B ** X ** ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this to the bwd.md from auto-docs.


Applying this proof rule turns the goal `Γ ; Γp ; P1, Γs ⊢ P2 ∗ Q`
into a new goal `Γ ; Γp ; Γs ⊢ Q`, where the assumption `P1` has been cancelled
against the conjunct `P2` in the conclusion as long as `P1` entails `P2`,
possibly via hints (`P1 ⊢~ P2`).

`P1 ⊢~ P2` holds in two cases:
- `P1` and `P2` unify; then we talk about identity cancellation, which is
essentially the frame rule
- `P1` entails `P2` via hints; then we just talk about cancellation

### Identity cancellation and unification

Unification in Rocq can unfold definitions, perform computation and instantiate
existential variables, but for efficient automation, we must restrict all these behaviors.

Unfolding arbitrary definitions can be very slow, but treating all definitions
as opaque can be too restrictive. Hence, we reuse Rocq's notion of hint opacity.

|*)

(*|
- `sep`

For efficiency, `sep` tests this typeclass unification

<!-- When can this instantiate evars? -->

In the simplest case,

More in general, one can cancel an assumption `P1` against a different conclusion
`P2` as long as we can deduce `P1 ⊢ P2` somehow.
```
Γ ; Γp ; Γs ⊢ Q

P1 |- P2
----------------------
Γ ; Γp ; P1, Γs ⊢ P2 ∗ Q
```

Cancellation solvers `sep`'s core proof rule is

`sep` will use the frame rule as long as the `ID_CANCEL`

### Unification

`sep` cannot use
While many introduction
`sep`

Our key strategy is to use the frame rule to cancel assumptions in `Γs` against conjuncts in `Q`, and to use hints to simplify the goal as much as possible before doing so.

Many separation logic connectives (universals, wands, joint conjunctions) have
syntax-directed proof rules.
However,
The exceptions are disjunctions

# Preliminaries

Iris entailments are turned into Iris goals, as if via `iStartProof`.

Take for instance
```rocq
HPA : Persistent A
AA : Affine A
_x_, _y_ : N
_Hyp_ : _x_ ≠ _y_
(1 / 1)
_ : A
--------------------------------------□
_ : B
--------------------------------------∗
C
```
Here `C` is the conclusion, `_ : B` is the spatial context, `_ : A` is the
intuitionistic context, and the rest is the Rocq context (which we'll usually
mostly elide).
|*)

Require Import iris.bi.bi.
Require Import skylabs_auto_core.examples.tutorial.automation.
Import iris.proofmode.proofmode.
Section with_prop.
Parameter PROP : bi.
Parameter A B C : PROP.
Context (HPA : Persistent A) (AA : Affine A).
(*
Axiom (HPA : Persistent A) (AA : Affine A).
Hint Resolve HPA AA : main.
*)

Goal ∀ x y : N, x <> y -> A ∗ B -∗ C.
Proof.
work.
wname [B] "B".
Abort.
End with_prop.

(*|

# Identity cancellation

`work` turns `Γp; A, B ⊢ A ∗ C` into `Γp; B ⊢ C`.
is solved by identity cancellation, which is enabled by the hint `ID_CANCEL`.

## Introduction rules

`work` turns goal `Hs ; Γp ; Γs ⊢ ∀ x : T, Q` into `Hs, x : T ; Γp ; Γs ⊢ Q`.

# Introduction
# Variable names

```
sep = fix rec. fwd*; learn*; cancel*; rec
```
It is designed

`sep` is an automated and extensible cancellation tactic for separation logic,
designed for automated proofs.

Our core proof strategy solves separation logic goals using

Other

Its core algorithm will:
- apply normalize the goal using
|*)
Loading