Coinductive formalization of unbounded computations. #
This file provides a Computation
type where Computation α
is the type of
unbounded computations returning α
.
Computation α
is the type of unbounded computations returning α
.
An element of Computation α
is an infinite sequence of Option α
such
that if f n = some a
for some n
then it is constantly some a
after that.
Equations
Instances For
think c
is the computation that delays for one "tick" and then performs
computation c
.
Equations
Instances For
thinkN c n
is the computation that delays for n
ticks and then performs
computation c
.
Equations
Instances For
runFor c n
evaluates c
for n
steps and returns the result, or none
if it did not terminate after n
steps.
Equations
Instances For
destruct c
is the destructor for Computation α
as a coinductive type.
It returns inl a
if c = pure a
and inr c'
if c = think c'
.
Equations
Instances For
run c
is an unsound meta function that runs c
to completion, possibly
resulting in an infinite loop in the VM.
Equations
Instances For
Recursion principle for computations, compare with List.recOn
.
Equations
Instances For
Bisimilarity over a sum of Computation
s
Equations
Instances For
Terminates s
asserts that the computation s
eventually terminates with some value.
assertion that there is some term
a
such that theComputation
terminates
Instances
Alias of Computation.notMem_empty
.
Promises s a
, or s ~> a
, asserts that although the computation s
may not terminate, if it does, then the result is a
.
Equations
Instances For
Promises s a
, or s ~> a
, asserts that although the computation s
may not terminate, if it does, then the result is a
.
Equations
Instances For
Results s a n
completely characterizes a terminating computation:
it asserts that s
terminates after exactly n
steps, with result a
.
Equations
Instances For
Recursor based on membership
Equations
Instances For
Recursor based on assertion of Terminates
Equations
Instances For
Map a function on the result of a computation.
Equations
Instances For
bind over a Sum
of Computation
Equations
Instances For
bind over a function mapping α
to a Computation
Equations
Instances For
Compose two computations into a monadic bind
operation.
Equations
Instances For
Flatten a computation of computations into a single computation.
Equations
Instances For
c₁ <|> c₂
calculates c₁
and c₂
simultaneously, returning
the first one that gives a result.
Equations
Instances For
c₁ ~ c₂
asserts that c₁
and c₂
either both terminate with the same result,
or both loop forever.
Equations
Instances For
equivalence relation for computations
Equations
Instances For
LiftRel R ca cb
is a generalization of Equiv
to relations other than
equality. It asserts that if ca
terminates with a
, then cb
terminates with
some b
such that R a b
, and if cb
terminates with b
then ca
terminates
with some a
such that R a b
.
Equations
Instances For
Alternate definition of LiftRel
over relations between Computation
s