Built with doc-gen4, running Lean4. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+โ†‘Ctrl+โ†“to navigate, Ctrl+๐Ÿ–ฑ๏ธto focus. On Mac, use Cmdinstead of Ctrl.
import Mt.Reservation
import Mt.Task.Impl

namespace Mt

/-- Monad to describe single threaded algorithms. Tasks can be iterated
  step by step until they finally complete or panic.

  `TaskM` is a monad, i.e. you can use the do-notation to write code:

  ```
  import Mt.Task.Basic
  open Mt

  abbrev spec : Spec :={
    State := Nat,
    Reservation := UnitReservation,
    validate :=ฮป _ _ => True
  }

  def sample_task : TaskM spec Bool :=do
    if (<- TaskM.atomic_read ฮป n => n) > 100 then
      -- reset to 100
      TaskM.atomic_read_modify ฮป _ => 100
      return false
    
    TaskM.atomic_assert ฮป n => n < 500
    
    TaskM.atomic_read_modify ฮป n => n + 7
    return true 
  ```

  Note: `TaskM` hat an associative bind operator, but it is not
  a lawful monad: Binding two `pure` cannot be simplified into
  a single pure, because it requires two iterations to complete.
-/
def 
TaskM: Spec โ†’ Type โ†’ Type
TaskM
(
spec: Spec
spec
:
Spec: Type 1
Spec
) (
T: Type
T
:
Type: Type 1
Type
) :
Type: Type 1
Type
:=
TaskM.impl.TaskM: Spec โ†’ Type โ†’ Type
TaskM.impl.TaskM
spec: Spec
spec
T: Type
T
/-- The result of a single iteration of `TaskM`. Independent of the result, the resulting shared state after the iteration can be retrieved using `IterationResult.state` -/ inductive
TaskM.IterationResult: Spec โ†’ Type โ†’ Type
TaskM.IterationResult
(
spec: Spec
spec
:
Spec: Type 1
Spec
) (
T: Type
T
:
Type: Type 1
Type
) |
Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
Done
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: Type
T
->
IterationResult: Spec โ†’ Type โ†’ Sort ?u.17
IterationResult
spec: Spec
spec
T: Type
T
|
Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
Panic
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
String: Type
String
->
IterationResult: Spec โ†’ Type โ†’ Sort ?u.17
IterationResult
spec: Spec
spec
T: Type
T
|
Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
Running
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
-> (
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
Bool: Type
Bool
) ->
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
->
IterationResult: Spec โ†’ Type โ†’ Sort ?u.17
IterationResult
spec: Spec
spec
T: Type
T
variable {
spec: Spec
spec
:
Spec: Type 1
Spec
} def
TaskM.IterationResult.state: {T : Type} โ†’ {spec : Spec} โ†’ IterationResult spec T โ†’ spec.State
TaskM.IterationResult.state
{
T: Type
T
spec: Spec
spec
} :
IterationResult: Spec โ†’ Type โ†’ Type
IterationResult
spec: ?m.1240
spec
T: ?m.1237
T
->
spec: ?m.1240
spec
.
State: Spec โ†’ Type
State
|
Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
Done
s: spec.State
s
_ =>
s: spec.State
s
|
Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
Panic
s: spec.State
s
_ =>
s: spec.State
s
|
Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
Running
s: spec.State
s
.. =>
s: spec.State
s
instance
TaskM.instMonad: {spec : Spec} โ†’ Monad (TaskM spec)
TaskM.instMonad
:
Monad: (Type ?u.1655 โ†’ Type ?u.1654) โ†’ Type (max (?u.1655 + 1) ?u.1654)
Monad
(
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
) where pure :=
impl.TaskM.pure: {spec : Spec} โ†’ {T : Type} โ†’ T โ†’ impl.TaskM spec T
impl.TaskM.pure
bind :=
impl.TaskM.bind: {spec : Spec} โ†’ {U V : Type} โ†’ impl.TaskM spec U โ†’ (U โ†’ impl.TaskM spec V) โ†’ impl.TaskM spec V
impl.TaskM.bind
theorem
TaskM.bind_assoc: โˆ€ {spec : Spec} {U V W : Type} (mu : TaskM spec U) (f : U โ†’ TaskM spec V) (g : V โ†’ TaskM spec W), (mu >>= fun u => f u >>= g) = mu >>= f >>= g
TaskM.bind_assoc
{
U: Type
U
V: Type
V
W: Type
W
:
Type: Type 1
Type
} (
mu: TaskM spec U
mu
:
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
U: Type
U
) (
f: U โ†’ TaskM spec V
f
:
U: Type
U
->
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
V: Type
V
) (
g: V โ†’ TaskM spec W
g
:
V: Type
V
->
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
W: Type
W
) :
mu: TaskM spec U
mu
>>= (fun
u: ?m.2694
u
=> (
f: U โ†’ TaskM spec V
f
u: ?m.2694
u
) >>=
g: V โ†’ TaskM spec W
g
) = (
mu: TaskM spec U
mu
>>=
f: U โ†’ TaskM spec V
f
) >>=
g: V โ†’ TaskM spec W
g
:=
spec: Spec

U, V, W: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

g: V โ†’ TaskM spec W


(mu >>= fun u => f u >>= g) = mu >>= f >>= g
spec: Spec

U, V, W: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

g: V โ†’ TaskM spec W


spec: Spec

U, V, W: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

g: V โ†’ TaskM spec W


(mu >>= fun u => f u >>= g) = mu >>= f >>= g

Goals accomplished! ๐Ÿ™
/-- Atomic `TaskM` primitive with read/write-access to the shared state. Additional to performing a read-modify operation, it returns a value. Example: Compare Exchange (https://en.wikipedia.org/wiki/Compare-and-swap) -/ def
TaskM.atomic_read_modify_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
TaskM.atomic_read_modify_read
{
T: Type
T
:
Type: Type 1
Type
} (
f: spec.State โ†’ T ร— spec.State
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: Type
T
ร—
spec: Spec
spec
.
State: Spec โ†’ Type
State
) :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
:=
impl.TaskM.atomic_read_modify_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T ร— spec.State) โ†’ impl.TaskM spec T
impl.TaskM.atomic_read_modify_read
f: spec.State โ†’ T ร— spec.State
f
/-- Atomic `TaskM` primitive to perform read-modify operations on the shared state. It does not return anything. -/ def
TaskM.atomic_read_modify: (spec.State โ†’ spec.State) โ†’ TaskM spec Unit
TaskM.atomic_read_modify
(
f: spec.State โ†’ spec.State
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
spec: Spec
spec
.
State: Spec โ†’ Type
State
) :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
Unit: Type
Unit
:=
atomic_read_modify_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
atomic_read_modify_read
ฮป
s: ?m.2960
s
=> โŸจ
โŸจโŸฉ: PUnit
โŸจโŸฉ
,
f: spec.State โ†’ spec.State
f
s: ?m.2960
s
โŸฉ /-- Atomic `TaskM` primitive to perform read the shared state. It does not change anything -/ def
TaskM.atomic_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T) โ†’ TaskM spec T
TaskM.atomic_read
{
T: Type
T
:
Type: Type 1
Type
} (
f: spec.State โ†’ T
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: Type
T
) :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
:=
atomic_read_modify_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
atomic_read_modify_read
ฮป
s: ?m.3046
s
=> match
f: spec.State โ†’ T
f
s: ?m.3046
s
with |
t: ?m.3049
t
=> โŸจ
t: ?m.3049
t
,
s: ?m.3046
s
โŸฉ /-- Atomic `TaskM` primitive which throws an exception. The current thread panics and will be removed from the system -/ def
TaskM.panic: {T : Type} โ†’ String โ†’ TaskM spec T
TaskM.panic
{
T: Type
T
:
Type: Type 1
Type
} (
msg: String
msg
:
String: Type
String
) :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
:=
impl.TaskM.panic: {spec : Spec} โ†’ {T : Type} โ†’ String โ†’ impl.TaskM spec T
impl.TaskM.panic
msg: String
msg
/-- Atomic `TaskM` primitive to assert a given condition. The condition is checked atomically. If it returns `false`, the current thread panics. -/ def
TaskM.atomic_assert: {spec : Spec} โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec Unit
TaskM.atomic_assert
(
cond: spec.State โ†’ Bool
cond
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
Bool: Type
Bool
) :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
Unit: Type
Unit
:=
impl.TaskM.atomic_assert: {spec : Spec} โ†’ (spec.State โ†’ Bool) โ†’ impl.TaskM spec Unit
impl.TaskM.atomic_assert
cond: spec.State โ†’ Bool
cond
/-- `TaskM` primitive which blocks the current thread until a given condition holds, and executes a read-modify-read operation afterwards. There are neither spurious wakeups nor race conditions: The system will only perform the read-modify-read operation if the provided condition holds. If it does not, the thread will block. -/ def
TaskM.atomic_blocking_rmr: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ Bool) โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
TaskM.atomic_blocking_rmr
(
block_until: spec.State โ†’ Bool
block_until
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
Bool: Type
Bool
) (
f: spec.State โ†’ T ร— spec.State
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: ?m.3233
T
ร—
spec: Spec
spec
.
State: Spec โ†’ Type
State
) :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: ?m.3233
T
:=
impl.TaskM.atomic_blocking_rmr: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ Bool) โ†’ (spec.State โ†’ T ร— spec.State) โ†’ impl.TaskM spec T
impl.TaskM.atomic_blocking_rmr
block_until: spec.State โ†’ Bool
block_until
f: spec.State โ†’ T ร— spec.State
f
/-- Iterate a given thread on a given state and provides an `IterationResult`. The task may complete or panic. If it is does not, it is still running and a continuation will be provided in the result -/ def
TaskM.iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
TaskM.iterate
{
T: Type
T
:
Type: Type 1
Type
} :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
->
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
IterationResult: Spec โ†’ Type โ†’ Type
IterationResult
spec: Spec
spec
T: Type
T
:= ฮป
p: ?m.3329
p
s: ?m.3332
s
=> match
p: ?m.3329
p
s: ?m.3332
s
with |
impl.IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ impl.IterationResult spec T
impl.IterationResult.Done
s': spec.State
s'
t: T
t
=>
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s': spec.State
s'
t: T
t
|
impl.IterationResult.Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ impl.IterationResult spec T
impl.IterationResult.Panic
s': spec.State
s'
msg: String
msg
=>
IterationResult.Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
IterationResult.Panic
s': spec.State
s'
msg: String
msg
|
impl.IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ (spec.State โ†’ impl.IterationResult spec T) โ†’ impl.IterationResult spec T
impl.IterationResult.Running
s': spec.State
s'
block_until: spec.State โ†’ Bool
block_until
cont: spec.State โ†’ impl.IterationResult spec T
cont
=>
IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
IterationResult.Running
s': spec.State
s'
block_until: spec.State โ†’ Bool
block_until
cont: spec.State โ†’ impl.IterationResult spec T
cont
/-- Iteration of `pure t` always completes with result `t` -/ theorem
TaskM.iterate_pure: โˆ€ {T : Type} (s : spec.State) (t : T), iterate (pure t) s = IterationResult.Done s t
TaskM.iterate_pure
{
T: Type
T
:
Type: Type 1
Type
} : โˆ€ (
s: spec.State
s
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
) (
t: T
t
:
T: Type
T
),
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
pure: {f : Type ?u.3757 โ†’ Type ?u.3756} โ†’ [self : Pure f] โ†’ {ฮฑ : Type ?u.3757} โ†’ ฮฑ โ†’ f ฮฑ
pure
t: T
t
)
s: spec.State
s
=
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s: spec.State
s
t: T
t
:=
spec: Spec

T: Type


โˆ€ (s : spec.State) (t : T), iterate (pure t) s = IterationResult.Done s t
spec: Spec

T: Type

sโœ: spec.State

tโœ: T


iterate (pure tโœ) sโœ = IterationResult.Done sโœ tโœ
spec: Spec

T: Type


โˆ€ (s : spec.State) (t : T), iterate (pure t) s = IterationResult.Done s t
spec: Spec

T: Type

sโœ: spec.State

tโœ: T


iterate (pure tโœ) sโœ = IterationResult.Done sโœ tโœ
spec: Spec

T: Type


โˆ€ (s : spec.State) (t : T), iterate (pure t) s = IterationResult.Done s t

Goals accomplished! ๐Ÿ™
/-- Iteration of `a >>= f` iterates `a` and returns a continuation. * If the `a` iteration has completed with result `t`, the next iteration will start work on `f t` * If the `a` iteration has not completed yet, the next iteration will continue. * If `a` has panicked, the exception is propagated. -/ theorem
TaskM.iterate_bind: โˆ€ {spec : Spec} {U V : Type} (mu : TaskM spec U) (f : U โ†’ TaskM spec V) (s : spec.State), iterate (mu >>= f) s = let _discr := iterate mu s; match iterate mu s with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (cont >>= f)
TaskM.iterate_bind
{
U: Type
U
V: Type
V
:
Type: Type 1
Type
} (
mu: TaskM spec U
mu
:
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
U: Type
U
) (
f: U โ†’ TaskM spec V
f
:
U: Type
U
->
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
V: Type
V
) : โˆ€ (
s: spec.State
s
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
),
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
mu: TaskM spec U
mu
>>=
f: U โ†’ TaskM spec V
f
)
s: spec.State
s
= match
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
mu: TaskM spec U
mu
s: spec.State
s
with |
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s': spec.State
s'
u: U
u
=>
IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
IterationResult.Running
s': spec.State
s'
(ฮป
_: ?m.3914
_
=>
true: Bool
true
) (
f: U โ†’ TaskM spec V
f
u: U
u
) |
IterationResult.Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
IterationResult.Panic
s': spec.State
s'
msg: String
msg
=>
IterationResult.Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
IterationResult.Panic
s': spec.State
s'
msg: String
msg
|
IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
IterationResult.Running
s': spec.State
s'
block_until: spec.State โ†’ Bool
block_until
cont: TaskM spec U
cont
=>
IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
IterationResult.Running
s': spec.State
s'
block_until: spec.State โ†’ Bool
block_until
(
cont: TaskM spec U
cont
>>=
f: U โ†’ TaskM spec V
f
) :=
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V


โˆ€ (s : spec.State), iterate (mu >>= f) s = let _discr := iterate mu s; match iterate mu s with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (cont >>= f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s: spec.State


iterate (mu >>= f) s = let _discr := iterate mu s; match iterate mu s with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (cont >>= f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V


โˆ€ (s : spec.State), iterate (mu >>= f) s = let _discr := iterate mu s; match iterate mu s with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (cont >>= f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s: spec.State


(match match h : mu s with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match mu s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V


โˆ€ (s : spec.State), iterate (mu >>= f) s = let _discr := iterate mu s; match iterate mu s with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (cont >>= f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s, aโœยน: spec.State

aโœ: U


Done
(match match h : impl.IterationResult.Done aโœยน aโœ with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match impl.IterationResult.Done aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s, aโœยน: spec.State

aโœ: String


Panic
(match match h : impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s, aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec U


Running
(match match h : impl.IterationResult.Running aโœยฒ aโœยน aโœ with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match impl.IterationResult.Running aโœยฒ aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s: spec.State


(match match h : mu s with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match mu s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s, aโœยน: spec.State

aโœ: U


Done
(match match h : impl.IterationResult.Done aโœยน aโœ with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match impl.IterationResult.Done aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s, aโœยน: spec.State

aโœ: String


Panic
(match match h : impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s, aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec U


Running
(match match h : impl.IterationResult.Running aโœยฒ aโœยน aโœ with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match impl.IterationResult.Running aโœยฒ aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)
spec: Spec

U, V: Type

mu: TaskM spec U

f: U โ†’ TaskM spec V

s: spec.State


(match match h : mu s with | impl.IterationResult.Done s' u => impl.IterationResult.Running s' (fun x => true) (f u) | impl.IterationResult.Panic s' msg => impl.IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => impl.IterationResult.Running s' block_until (impl.TaskM.bind cont f) with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = match match mu s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont with | IterationResult.Done s' u => IterationResult.Running s' (fun x => true) (f u) | IterationResult.Panic s' msg => IterationResult.Panic s' msg | IterationResult.Running s' block_until cont => IterationResult.Running s' block_until (impl.TaskM.bind cont f)

Goals accomplished! ๐Ÿ™
/-- Iteration of a read-modify-read-operation will perform the read modify and complete with the computed result. -/ theorem
TaskM.iterate_rmr: โˆ€ {T : Type} (f : spec.State โ†’ T ร— spec.State) (s : spec.State), iterate (atomic_read_modify_read f) s = let _discr := f s; match f s with | (t, s') => IterationResult.Done s' t
TaskM.iterate_rmr
{
T: Type
T
:
Type: Type 1
Type
} (
f: spec.State โ†’ T ร— spec.State
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: Type
T
ร—
spec: Spec
spec
.
State: Spec โ†’ Type
State
) : โˆ€
s: ?m.7722
s
,
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
atomic_read_modify_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
atomic_read_modify_read
f: spec.State โ†’ T ร— spec.State
f
)
s: ?m.7722
s
= match
f: spec.State โ†’ T ร— spec.State
f
s: ?m.7722
s
with | โŸจ
t: T
t
,
s': spec.State
s'
โŸฉ =>
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s': spec.State
s'
t: T
t
:=
spec: Spec

T: Type

f: spec.State โ†’ T ร— spec.State


โˆ€ (s : spec.State), iterate (atomic_read_modify_read f) s = let _discr := f s; match f s with | (t, s') => IterationResult.Done s' t
spec: Spec

T: Type

f: spec.State โ†’ T ร— spec.State

sโœ: spec.State


iterate (atomic_read_modify_read f) sโœ = let _discr := f sโœ; match f sโœ with | (t, s') => IterationResult.Done s' t
spec: Spec

T: Type

f: spec.State โ†’ T ร— spec.State


โˆ€ (s : spec.State), iterate (atomic_read_modify_read f) s = let _discr := f s; match f s with | (t, s') => IterationResult.Done s' t
spec: Spec

T: Type

f: spec.State โ†’ T ร— spec.State

sโœ: spec.State


iterate (atomic_read_modify_read f) sโœ = let _discr := f sโœ; match f sโœ with | (t, s') => IterationResult.Done s' t
spec: Spec

T: Type

f: spec.State โ†’ T ร— spec.State


โˆ€ (s : spec.State), iterate (atomic_read_modify_read f) s = let _discr := f s; match f s with | (t, s') => IterationResult.Done s' t

Goals accomplished! ๐Ÿ™
/-- Iteration of a read-modify operation will perform the read modify operation and complete with `Unit.unit` -/ theorem
TaskM.iterate_rm: โˆ€ (f : spec.State โ†’ spec.State) (s : spec.State), iterate (atomic_read_modify f) s = let s' := f s; IterationResult.Done s' PUnit.unit
TaskM.iterate_rm
(
f: spec.State โ†’ spec.State
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
spec: Spec
spec
.
State: Spec โ†’ Type
State
) : โˆ€
s: ?m.7888
s
,
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
atomic_read_modify: {spec : Spec} โ†’ (spec.State โ†’ spec.State) โ†’ TaskM spec Unit
atomic_read_modify
f: spec.State โ†’ spec.State
f
)
s: ?m.7888
s
= match
f: spec.State โ†’ spec.State
f
s: ?m.7888
s
with |
s': ?m.7904
s'
=>
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s': ?m.7904
s'
โŸจโŸฉ: PUnit
โŸจโŸฉ
:=
spec: Spec

f: spec.State โ†’ spec.State


โˆ€ (s : spec.State), iterate (atomic_read_modify f) s = let s' := f s; IterationResult.Done s' PUnit.unit

Goals accomplished! ๐Ÿ™
/-- Iteration of a read operation will compute a value based on the current shared state and complete with the result -/ theorem
TaskM.iterate_read: โˆ€ {spec : Spec} {T : Type} (f : spec.State โ†’ T ร— spec.Reservation) (s : spec.State), iterate (atomic_read f) s = let t := f s; IterationResult.Done s t
TaskM.iterate_read
(
f: spec.State โ†’ T ร— spec.Reservation
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: ?m.8188
T
ร—
spec: Spec
spec
.
Reservation: Spec โ†’ Type
Reservation
) : โˆ€
s: ?m.8198
s
,
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
atomic_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T) โ†’ TaskM spec T
atomic_read
f: spec.State โ†’ T ร— spec.Reservation
f
)
s: ?m.8198
s
= match
f: spec.State โ†’ T ร— spec.Reservation
f
s: ?m.8198
s
with |
t: ?m.8217
t
=>
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s: ?m.8198
s
t: ?m.8217
t
:=
spec: Spec

T: Type

f: spec.State โ†’ T ร— spec.Reservation


โˆ€ (s : spec.State), iterate (atomic_read f) s = let t := f s; IterationResult.Done s t

Goals accomplished! ๐Ÿ™
/-- Iteration of a panic will fail -/ theorem
TaskM.iterate_panic: โˆ€ {spec : Spec} {T : Type} (msg : String) (s : spec.State), iterate (panic msg) s = IterationResult.Panic s msg
TaskM.iterate_panic
{
T: Type
T
:
Type: Type 1
Type
} (
msg: String
msg
:
String: Type
String
) : โˆ€ (
s: spec.State
s
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
),
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
panic: {spec : Spec} โ†’ {T : Type} โ†’ String โ†’ TaskM spec T
panic
(T :=
T: Type
T
)
msg: String
msg
)
s: spec.State
s
=
IterationResult.Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
IterationResult.Panic
s: spec.State
s
msg: String
msg
:=
spec: Spec

T: Type

msg: String


โˆ€ (s : spec.State), iterate (panic msg) s = IterationResult.Panic s msg
spec: Spec

T: Type

msg: String

sโœ: spec.State


iterate (panic msg) sโœ = IterationResult.Panic sโœ msg
spec: Spec

T: Type

msg: String


โˆ€ (s : spec.State), iterate (panic msg) s = IterationResult.Panic s msg
spec: Spec

T: Type

msg: String

sโœ: spec.State


iterate (panic msg) sโœ = IterationResult.Panic sโœ msg
spec: Spec

T: Type

msg: String


โˆ€ (s : spec.State), iterate (panic msg) s = IterationResult.Panic s msg

Goals accomplished! ๐Ÿ™
/-- Iteration of an assertion will atomically check the condition and succeed or fail depending on the result. -/ theorem
TaskM.iterate_assert: โˆ€ {spec : Spec} (cond : spec.State โ†’ Bool) (s : spec.State), iterate (atomic_assert cond) s = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
TaskM.iterate_assert
(
cond: spec.State โ†’ Bool
cond
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
Bool: Type
Bool
) : โˆ€
s: ?m.8539
s
,
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
atomic_assert: {spec : Spec} โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec Unit
atomic_assert
cond: spec.State โ†’ Bool
cond
)
s: ?m.8539
s
= if
cond: spec.State โ†’ Bool
cond
s: ?m.8539
s
then
IterationResult.Done: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ T โ†’ IterationResult spec T
IterationResult.Done
s: ?m.8539
s
โŸจโŸฉ: PUnit
โŸจโŸฉ
else
IterationResult.Panic: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ String โ†’ IterationResult spec T
IterationResult.Panic
s: ?m.8539
s
"Assertion failed": String
"Assertion failed"
:=
spec: Spec

cond: spec.State โ†’ Bool


โˆ€ (s : spec.State), iterate (atomic_assert cond) s = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


iterate (atomic_assert cond) s = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
spec: Spec

cond: spec.State โ†’ Bool


โˆ€ (s : spec.State), iterate (atomic_assert cond) s = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


(match if cond s = true then impl.IterationResult.Done s PUnit.unit else impl.IterationResult.Panic s "Assertion failed" with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
spec: Spec

cond: spec.State โ†’ Bool


โˆ€ (s : spec.State), iterate (atomic_assert cond) s = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


false
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


true
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


(match if cond s = true then impl.IterationResult.Done s PUnit.unit else impl.IterationResult.Panic s "Assertion failed" with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


false
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


true
spec: Spec

cond: spec.State โ†’ Bool

s: spec.State


(match if cond s = true then impl.IterationResult.Done s PUnit.unit else impl.IterationResult.Panic s "Assertion failed" with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = if cond s = true then IterationResult.Done s PUnit.unit else IterationResult.Panic s "Assertion failed"

Goals accomplished! ๐Ÿ™
/-- Iteration of a `atomic_blocking_rmr` operation will always return a continuation. The `IterationResult` contains the blocking predicate and the desired read-modify-read operation. The caller should ensure that the read-modify-operation is only iterated when the blocking predicate holds. -/ theorem
TaskM.iterate_blocking_rmr: โˆ€ {spec : Spec} {T : Type} (block_until : spec.State โ†’ Bool) (f : spec.State โ†’ T ร— spec.State) (s : spec.State), iterate (atomic_blocking_rmr block_until f) s = IterationResult.Running s block_until (atomic_read_modify_read f)
TaskM.iterate_blocking_rmr
(
block_until: spec.State โ†’ Bool
block_until
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
Bool: Type
Bool
) (
f: spec.State โ†’ T ร— spec.State
f
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
T: ?m.9923
T
ร—
spec: Spec
spec
.
State: Spec โ†’ Type
State
) : โˆ€
s: ?m.9937
s
,
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
(
atomic_blocking_rmr: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ Bool) โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
atomic_blocking_rmr
block_until: spec.State โ†’ Bool
block_until
f: spec.State โ†’ T ร— spec.State
f
)
s: ?m.9937
s
=
IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
IterationResult.Running
s: ?m.9937
s
block_until: spec.State โ†’ Bool
block_until
(
atomic_read_modify_read: {spec : Spec} โ†’ {T : Type} โ†’ (spec.State โ†’ T ร— spec.State) โ†’ TaskM spec T
atomic_read_modify_read
f: spec.State โ†’ T ร— spec.State
f
) :=
spec: Spec

T: Type

block_until: spec.State โ†’ Bool

f: spec.State โ†’ T ร— spec.State


โˆ€ (s : spec.State), iterate (atomic_blocking_rmr block_until f) s = IterationResult.Running s block_until (atomic_read_modify_read f)
spec: Spec

T: Type

block_until: spec.State โ†’ Bool

f: spec.State โ†’ T ร— spec.State

sโœ: spec.State


iterate (atomic_blocking_rmr block_until f) sโœ = IterationResult.Running sโœ block_until (atomic_read_modify_read f)
spec: Spec

T: Type

block_until: spec.State โ†’ Bool

f: spec.State โ†’ T ร— spec.State


โˆ€ (s : spec.State), iterate (atomic_blocking_rmr block_until f) s = IterationResult.Running s block_until (atomic_read_modify_read f)
spec: Spec

T: Type

block_until: spec.State โ†’ Bool

f: spec.State โ†’ T ร— spec.State

sโœ: spec.State


iterate (atomic_blocking_rmr block_until f) sโœ = IterationResult.Running sโœ block_until (atomic_read_modify_read f)
spec: Spec

T: Type

block_until: spec.State โ†’ Bool

f: spec.State โ†’ T ร— spec.State


โˆ€ (s : spec.State), iterate (atomic_blocking_rmr block_until f) s = IterationResult.Running s block_until (atomic_read_modify_read f)

Goals accomplished! ๐Ÿ™
/-- Well founded relation on `TaskM` fulfilled by continuations with their parents. It can be used to perform well founded recursion `TaskM` without using the implementation details of `TaskM`. Whenever `TaskM.iterate` returns a continuation, the continuation will be *smaller* according to this relation. -/ inductive
TaskM.is_direct_cont: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ TaskM spec T โ†’ Prop
TaskM.is_direct_cont
{
T: Type
T
:
Type: Type 1
Type
} :
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
->
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
->
Prop: Type
Prop
|
running: โˆ€ {spec : Spec} {T : Type} {p cont : TaskM spec T} {s s' : spec.State} {block_until : spec.State โ†’ Bool}, iterate p s = IterationResult.Running s' block_until cont โ†’ is_direct_cont cont p
running
{
p: TaskM spec T
p
cont: TaskM spec T
cont
:
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
} {
s: ?m.10035
s
s': ?m.10038
s'
} {
block_until: spec.State โ†’ Bool
block_until
:
spec: Spec
spec
.
State: Spec โ†’ Type
State
->
Bool: Type
Bool
} (
iteration: iterate p s = IterationResult.Running s' block_until cont
iteration
:
p: TaskM spec T
p
.
iterate: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ spec.State โ†’ IterationResult spec T
iterate
s: ?m.10035
s
=
IterationResult.Running: {spec : Spec} โ†’ {T : Type} โ†’ spec.State โ†’ (spec.State โ†’ Bool) โ†’ TaskM spec T โ†’ IterationResult spec T
IterationResult.Running
s': ?m.10038
s'
block_until: spec.State โ†’ Bool
block_until
cont: TaskM spec T
cont
) :
is_direct_cont: {T : Type} โ†’ TaskM spec T โ†’ TaskM spec T โ†’ Prop
is_direct_cont
cont: TaskM spec T
cont
p: TaskM spec T
p
/-- See `TaskM.is_direct_cont` -/ theorem
TaskM.is_direct_cont_wf: โˆ€ {spec : Spec} {T : Type}, WellFounded is_direct_cont
TaskM.is_direct_cont_wf
{
T: Type
T
:
Type: Type 1
Type
} :
WellFounded: {ฮฑ : Sort ?u.10114} โ†’ (ฮฑ โ†’ ฮฑ โ†’ Prop) โ†’ Prop
WellFounded
(@
is_direct_cont: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ TaskM spec T โ†’ Prop
is_direct_cont
spec: Spec
spec
T: Type
T
) :=
spec: Spec

T: Type


WellFounded is_direct_cont
spec: Spec

T: Type


h
โˆ€ (a : TaskM spec T), Acc is_direct_cont a
spec: Spec

T: Type


WellFounded is_direct_cont
spec: Spec

T: Type


h
โˆ€ (a : TaskM spec T), Acc is_direct_cont a
spec: Spec

T: Type


WellFounded is_direct_cont
spec: Spec

T: Type

p: impl.TaskM spec T


h
Acc is_direct_cont p
spec: Spec

T: Type


WellFounded is_direct_cont
spec: Spec

T: Type

p: impl.TaskM spec T


h.hwf
WellFounded ?m.10203
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type


WellFounded is_direct_cont
spec: Spec

T: Type

p: impl.TaskM spec T


h.hwf
WellFounded ?m.10203
spec: Spec

T: Type

p: impl.TaskM spec T


h.hwf
WellFounded ?m.10203
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ

Goals accomplished! ๐Ÿ™
spec: Spec

T: Type


WellFounded is_direct_cont
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y


h.h
Acc is_direct_cont p
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y


h.h.h
โˆ€ (y : TaskM spec T), is_direct_cont y p โ†’ Acc is_direct_cont y
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y


h.h.h
โˆ€ (y : TaskM spec T), is_direct_cont y p โ†’ Acc is_direct_cont y
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

is_cont: is_direct_cont cont p


h.h.h
Acc is_direct_cont cont
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

is_cont: is_direct_cont cont p


h.h.h.a
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

sโœ, s'โœ: spec.State

block_untilโœ: spec.State โ†’ Bool


h.h.h.a.running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: iterate p s = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: iterate p s = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยน: spec.State

aโœ: T

h: p s = impl.IterationResult.Done aโœยน aโœ


h.h.h.a.running.Done
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยน: spec.State

aโœ: String

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยน: spec.State

aโœ: T

h: p s = impl.IterationResult.Done aโœยน aโœ


h.h.h.a.running.Done
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยน: spec.State

aโœ: String

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont


h.h.h.a.running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

iteration: (match impl.IterationResult.Running aโœยฒ aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยน: spec.State

aโœ: String

iteration: (match impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

iteration: (match impl.IterationResult.Running aโœยฒ aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยน: spec.State

aโœ: String

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยน: spec.State

aโœ: String

iteration: (match impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

iteration: (match p s with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

aโœยน: spec.State

aโœ: String

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยน: spec.State

aโœ: String

iteration: (match impl.IterationResult.Panic aโœยน aโœ with | impl.IterationResult.Done s' t => IterationResult.Done s' t | impl.IterationResult.Panic s' msg => IterationResult.Panic s' msg | impl.IterationResult.Running s' block_until cont => IterationResult.Running s' block_until cont) = IterationResult.Running s' block_until cont

h: p s = impl.IterationResult.Panic aโœยน aโœ


h.h.h.a.running.Panic

Goals accomplished! ๐Ÿ™
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ


h.h.h.a.running.Running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ

cont'_def: aโœ = cont


h.h.h.a.running.Running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ

cont'_def: aโœ = cont


h.h.h.a.running.Running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน aโœ

cont'_def: aโœ = cont


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน cont

cont'_def: aโœ = cont


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน cont

cont'_def: aโœ = cont


h.h.h.a.running.Running
spec: Spec

T: Type

p: impl.TaskM spec T

IH: โˆ€ (y : impl.TaskM spec T), impl.TaskM.is_direct_cont y p โ†’ Acc is_direct_cont y

cont: TaskM spec T

s, s': spec.State

block_until: spec.State โ†’ Bool

aโœยฒ: spec.State

aโœยน: spec.State โ†’ Bool

aโœ: spec.State โ†’ impl.IterationResult spec T

h: p s = impl.IterationResult.Running aโœยฒ aโœยน cont

cont'_def: aโœ = cont


h.h.h.a.running.Running
spec: Spec

T: Type

p, xโœ: impl.TaskM spec T


h.h
Acc is_direct_cont xโœ

Goals accomplished! ๐Ÿ™
instance
TaskM.instWf: {spec : Spec} โ†’ {T : Type} โ†’ WellFoundedRelation (TaskM spec T)
TaskM.instWf
{
T: Type
T
:
Type: Type 1
Type
} :
WellFoundedRelation: Sort ?u.10763 โ†’ Sort (max 1 ?u.10763)
WellFoundedRelation
(
TaskM: Spec โ†’ Type โ†’ Type
TaskM
spec: Spec
spec
T: Type
T
) where rel :=
is_direct_cont: {spec : Spec} โ†’ {T : Type} โ†’ TaskM spec T โ†’ TaskM spec T โ†’ Prop
is_direct_cont
wf :=
is_direct_cont_wf: โˆ€ {spec : Spec} {T : Type}, WellFounded is_direct_cont
is_direct_cont_wf
end Mt