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.System.Basic
import Mt.System.BasicAux
import Mt.System.Traced
import Mt.Utils.List

namespace Mt.System

variable {
spec: Spec
spec
:
Spec: Type 1
Spec
} local
instance: {spec : Spec} → IsReservation spec.Reservation
instance
:
IsReservation: TypeType
IsReservation
spec: Spec
spec
.
Reservation: SpecType
Reservation
:=
spec: Spec
spec
.
is_reservation: (self : Spec) → IsReservation self.Reservation
is_reservation
open Utils /-- Central validation predicate for reasoning about systems. A valid system has the following property: Given any future iteration of the system (or the system itself), the following holds: * No threads have panicked yet (and they never will) * Its current state is valid according to the specification -/ def
valid: {spec : Spec} → System specProp
valid
(
s: System spec
s
:
System: SpecType 1
System
spec: Spec
spec
) :
Prop: Type
Prop
:= ∀
s': System spec
s'
:
System: SpecType 1
System
spec: Spec
spec
,
s: System spec
s
.
reduces_to_or_eq: {spec : Spec} → System specSystem specProp
reduces_to_or_eq
s': System spec
s'
s': System spec
s'
.
panics: {spec : Spec} → System specNat
panics
=
0: ?m.45
0
∧ ∃
r: ?m.66
r
,
spec: Spec
spec
.
validate: (self : Spec) → self.Reservationself.StateProp
validate
r: ?m.66
r
s': System spec
s'
.
state: {spec : Spec} → System specspec.State
state
theorem
fundamental_validation_theorem: ∀ (s : System spec), s.panics = 0Spec.validate spec IsReservation.empty s.state(∀ (t : Thread spec), t s.threadsThread.valid t) → valid s
fundamental_validation_theorem
(
s: System spec
s
:
System: SpecType 1
System
spec: Spec
spec
) (
no_panics_yet: s.panics = 0
no_panics_yet
:
s: System spec
s
.
panics: {spec : Spec} → System specNat
panics
=
0: ?m.92
0
) (
initial_valid: Spec.validate spec IsReservation.empty s.state
initial_valid
:
spec: Spec
spec
.
validate: (self : Spec) → self.Reservationself.StateProp
validate
IsReservation.empty: {T : Type} → [self : IsReservation T] → T
IsReservation.empty
s: System spec
s
.
state: {spec : Spec} → System specspec.State
state
) (
threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t
threads_valid
: ∀
t: ?m.123
t
,
t: ?m.123
t
s: System spec
s
.
threads: {spec : Spec} → System specList (Thread spec)
threads
t: ?m.123
t
.
valid: {spec : Spec} → Thread specProp
valid
) :
s: System spec
s
.
valid: {spec : Spec} → System specProp
valid
:=
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

s_to_s': reduces_to_or_eq s s'


s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec


inr
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

s_to_s': reduces_to_or_eq s s'


s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec


inr
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

s_to_s': reduces_to_or_eq s s'


s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'


inr
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s.panics = 0 r, Spec.validate spec r s.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s.panics = 0 r, Spec.validate spec r s.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: s = s'


inl
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'


inr
s'.panics = 0 r, Spec.validate spec r s'.state

Goals accomplished! 🐙
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec


inr
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced


inr
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced


inr
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

w✝: Traced.TracedSystem spec


intro
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

this: ts, Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

ts: Traced.TracedSystem spec

ts_hyp: Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


intro
s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

this: ts, Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

ts: Traced.TracedSystem spec

ts_hyp: Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


intro
r, Spec.validate spec r ts.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

this: ts, Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


s'.panics = 0 r, Spec.validate spec r s'.state
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

ts: Traced.TracedSystem spec

ts_hyp: Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


intro
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced

this: ts, Traced.TracedSystem.to_system ts = s' Traced.TracedSystem.valid ts


s'.panics = 0 r, Spec.validate spec r s'.state

Goals accomplished! 🐙
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced


inr
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

s': System spec

h: reduces_to s s'

traced:= Traced.TracedSystem.mk_initial s: Traced.TracedSystem spec

traced_valid: Traced.TracedSystem.valid traced


inr

Goals accomplished! 🐙
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s': System spec

idx: ThreadIndex s

iteration: iterate s idx = s'


inr.single
spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s': System spec

idx: ThreadIndex s

iteration: iterate s idx = s'

ts: Traced.TracedSystem spec

ts_valid: Traced.TracedSystem.valid ts

s_def: s = Traced.TracedSystem.to_system ts


inr.single
spec: Spec

s, s', a✝, b✝: System spec

idx✝: ThreadIndex a✝


inr.single
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans

Goals accomplished! 🐙
spec: Spec

s: System spec

no_panics_yet: s.panics = 0

initial_valid: Spec.validate spec IsReservation.empty s.state

threads_valid: ∀ (t : Thread spec), t s.threadsThread.valid t


spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans

Goals accomplished! 🐙
spec: Spec

s, s', a✝, b✝, c✝: System spec


inr.trans

Goals accomplished! 🐙
end Mt.System