Documentation

Strata.Util.Relations

def Relation (A : Type) :
Equations
Instances For
    def IsReflexive {A : Type} (r : Relation A) :
    Equations
    Instances For
      @[reducible, inline]
      abbrev IsTransitive {A : Type} (r : Relation A) :
      Equations
      Instances For
        def RComp {A : Type} (R₁ R₂ : Relation A) :

        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.

        Equations
        Instances For
          inductive ReflTrans {A : Type} (r : Relation A) :

          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.

          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:

            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.

            inductive ReflTransT {A : Type} (r : A → A → Prop) :
            A → A → Type
            Instances For
              theorem reflTrans_nonempty_T {A : Type} {r : A → A → Prop} {a b : A} :
              ReflTrans r a b → Nonempty (ReflTransT r a b)
              noncomputable def reflTrans_to_T {A : Type} {r : A → A → Prop} {a b : A} :
              ReflTrans r a b → ReflTransT r a b
              Equations
              Instances For
                def ReflTransT.len {A : Type} {r : A → A → Prop} {a b : A} :
                ReflTransT r a b → Nat
                Equations
                Instances For

                  Trace-producing reflexive transitive closure #

                  inductive ReflTransTrace {A E : Type} (r : A → List E → A → Prop) :
                  A → List E → A → Prop

                  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.

                    inductive ReflTransTraceT {A E : Type} (r : A → List E → A → Prop) :
                    A → List E → A → Type
                    Instances For
                      def ReflTransTraceT.len {A E : Type} {r : A → List E → A → Prop} {a : A} {tr : List E} {b : A} :
                      ReflTransTraceT r a tr b → Nat
                      Equations
                      Instances For