Equations
- IsReflexive r = ∀ (x : A), r x x
Instances For
Composition of two relations: RComp R₁ R₂ a c holds when some intermediate
b has R₁ a b and R₂ b c. Read left-to-right: "first R₁, then R₂".
The scoped notation R₁ ∘ R₂ is available via open scoped Relations.
Instances For
Equations
- Relations.«term_∘_» = Lean.ParserDescr.trailingNode `Relations.«term_∘_» 90 91 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ∘ ") (Lean.ParserDescr.cat `term 90))
Instances For
r is dense when every related pair has an interpolating midpoint:
r a c splits into r a b and r b c. This is exactly r ⊆ RComp r r,
the dual of RComp.collapse's RComp r r ⊆ r (transitivity): density lets a
single relatedness fact be re-expressed as the two-step form that a composed
relation consumes.
- refl {A : Type} {r : Relation A} (x : A) : ReflTrans r x x
- step {A : Type} {r : Relation A} (x y z : A) : r x y → ReflTrans r y z → ReflTrans r x z
Instances For
Type-valued reflexive transitive closure #
ReflTrans lives in Prop, so Lean's large-elimination restriction forbids
pattern-matching on it to produce data (e.g. a Nat step count).
ReflTransT is the identical definition but in Type, which allows:
- Structural recursion on derivations — useful when a proof needs well-founded recursion keyed on the length of a multi-step execution (e.g. loop-simulation arguments where each iteration strictly shrinks the remaining trace).
- Step counting via
ReflTransT.len— enablestermination_by/decreasing_byon the derivation length.
Convert between the two with reflTrans_nonempty_T (Prop → Nonempty Type)
and reflTransT_to_prop (Type → Prop). The Prop-to-Type direction requires
Classical.choice (reflTrans_to_T), so definitions that use it are
noncomputable; this is harmless when the final result is again a Prop.
- refl {A : Type} {r : A → A → Prop} (x : A) : ReflTransT r x x
- step {A : Type} {r : A → A → Prop} (x y z : A) : r x y → ReflTransT r y z → ReflTransT r x z
Instances For
Equations
Instances For
Equations
- (ReflTransT.refl a).len = 0
- (ReflTransT.step a y b a_1 rest).len = 1 + rest.len
Instances For
Trace-producing reflexive transitive closure #
IsReflexive-transitive closure of a relation whose steps emit a list of observations. The accumulated trace is chronological: a step's output precedes the trace emitted by the remaining execution.
- refl
{A E : Type}
{r : A → List E → A → Prop}
(x : A)
: ReflTransTrace r x [] x
IsReflexive execution emits the empty trace.
- step
{A E : Type}
{r : A → List E → A → Prop}
(x : A)
(emitted : List E)
(y : A)
(rest : List E)
(z : A)
: r x emitted y → ReflTransTrace r y rest z → ReflTransTrace r x (emitted ++ rest) z
Prepend one labeled step to a traced execution, concatenating its events before the remaining trace.
Instances For
Type-valued trace-producing reflexive transitive closure #
The Type-valued analogue of ReflTransTrace, standing to it as ReflTransT
does to ReflTrans. Living in Type permits structural recursion on a traced
derivation to produce data — in particular a step count via
ReflTransTraceT.len — which is what lets a loop-simulation argument recurse on
the strictly shrinking length of the remaining execution while still tracking
the chronological trace it emits.
- refl {A E : Type} {r : A → List E → A → Prop} (x : A) : ReflTransTraceT r x [] x
- step {A E : Type} {r : A → List E → A → Prop} (x : A) (emitted : List E) (y : A) (rest : List E) (z : A) : r x emitted y → ReflTransTraceT r y rest z → ReflTransTraceT r x (emitted ++ rest) z
Instances For
Equations
- (ReflTransTraceT.refl x✝).len = 0
- (ReflTransTraceT.step x✝¹ emitted y rest x✝ a rest_1).len = 1 + rest_1.len