Documentation

Cslib.Foundations.Data.RelatesInSteps

Relations Across Steps #

This file defines Relation.RelatesInSteps (and Relation.RelatesWithinSteps). These are inductively defined propositions that communicate whether a relation forms a chain of length n (or at most n) between two elements.

The lemma RelatesInSteps.exists_isChainFromTo allows to obtain a chain (List.IsChainFromTo) of related elements that witness the reachability, and List.IsChainFromTo.relatesInSteps is the converse direction. Relation.relatesInSteps_iff_exists_isChainFromTo combines both.

Another result is Relation.ReflTransGen.relatesInSteps_lt_encard, which states that any element reachable from a is reachable in fewer steps than there are elements reachable from a.

inductive Relation.RelatesInSteps {α : Type u_1} (r : ααProp) :
ααProp

A relation r relates two elements of α in n steps if there is a chain of n pairs (t_i, t_{i+1}) such that r t_i t_{i+1} for each i, starting from the first element and ending at the second.

Instances For
    theorem Relation.RelatesInSteps.reflTransGen {α : Type u_1} {r : ααProp} {a b : α} {n : } (h : RelatesInSteps r a b n) :
    theorem Relation.ReflTransGen.relatesInSteps {α : Type u_1} {r : ααProp} {a b : α} (h : ReflTransGen r a b) :
    ∃ (n : ), RelatesInSteps r a b n

    If b is reachable from a via r, then they relate to each other for some number of steps.

    theorem Relation.RelatesInSteps.single {α : Type u_1} {r : ααProp} {a b : α} (h : r a b) :
    theorem Relation.RelatesInSteps.head {α : Type u_1} {r : ααProp} (t t' t'' : α) (n : ) (h₁ : r t t') (h₂ : RelatesInSteps r t' t'' n) :
    RelatesInSteps r t t'' (n + 1)
    theorem Relation.RelatesInSteps.head_induction_on {α : Type u_1} {r : ααProp} {b : α} {motive : (a : α) → (n : ) → RelatesInSteps r a b nProp} {a : α} {n : } (h : RelatesInSteps r a b n) (hrefl : motive b 0 ) (hhead : ∀ {a c : α} {n : } (h' : r a c) (h : RelatesInSteps r c b n), motive c n hmotive a (n + 1) ) :
    motive a n h
    theorem Relation.RelatesInSteps.zero {α : Type u_1} {r : ααProp} {a b : α} (h : RelatesInSteps r a b 0) :
    a = b
    @[simp]
    theorem Relation.RelatesInSteps.zero_iff {α : Type u_1} {r : ααProp} {a b : α} :
    RelatesInSteps r a b 0 a = b
    theorem Relation.RelatesInSteps.trans {α : Type u_1} {r : ααProp} {a b c : α} {n m : } (h₁ : RelatesInSteps r a b n) (h₂ : RelatesInSteps r b c m) :
    RelatesInSteps r a c (n + m)
    theorem Relation.RelatesInSteps.succ {α : Type u_1} {r : ααProp} {a b : α} {n : } (h : RelatesInSteps r a b (n + 1)) :
    ∃ (t' : α), RelatesInSteps r a t' n r t' b
    theorem Relation.RelatesInSteps.succ_iff {α : Type u_1} {r : ααProp} {a b : α} {n : } :
    RelatesInSteps r a b (n + 1) ∃ (t' : α), RelatesInSteps r a t' n r t' b
    theorem Relation.RelatesInSteps.succ' {α : Type u_1} {r : ααProp} {a b : α} {n : } (h : RelatesInSteps r a b (n + 1)) :
    ∃ (t' : α), r a t' RelatesInSteps r t' b n
    theorem Relation.RelatesInSteps.succ'_iff {α : Type u_1} {r : ααProp} {a b : α} {n : } :
    RelatesInSteps r a b (n + 1) ∃ (t' : α), r a t' RelatesInSteps r t' b n
    theorem Relation.RelatesInSteps.apply_le_apply_add {α : Type u_1} {r : ααProp} {a b : α} {m : } (hevals : RelatesInSteps r a b m) (h : α) (h_step : ∀ (a b : α), r a bh b h a + 1) :
    h b h a + m

    If h : α → ℕ increases by at most 1 on each step of r, then the value of h at the output is at most h at the input plus the number of steps.

    theorem Relation.RelatesInSteps.map {α : Type u_2} {α' : Type u_3} {r : ααProp} {r' : α'α'Prop} (g : αα') (hg : ∀ (a b : α), r a br' (g a) (g b)) {a b : α} {n : } (h : RelatesInSteps r a b n) :
    RelatesInSteps r' (g a) (g b) n

    If g is a homomorphism from r to r' (i.e., it preserves the reduction relation), then RelatesInSteps is preserved under g.

    Translating between RelatesInSteps and chains (List.IsChainFromTo) #

    theorem Relation.RelatesInSteps.exists_isChainFromTo {α : Type u_1} {r : ααProp} {a b : α} {n : } (h : RelatesInSteps r a b n) :
    ∃ (chain : List α), List.IsChainFromTo r chain a b chain.length = n + 1

    If b is related to a via r in n steps, then there is an r-chain of n + 1 elements starting at a and ending at b. This is similar to List.exists_isChain_ne_nil_of_relationReflTransGen, but also provides a length guarantee.

    theorem List.IsChain.relatesInSteps_getElem {α : Type u_1} {r : ααProp} {chain : List α} (hc : IsChain r chain) (i k : ) (hik : i + k < chain.length) :
    Relation.RelatesInSteps r chain[i] chain[i + k] k

    Any two elements along an r-chain are related in as many steps as their distance in the chain.

    theorem List.IsChainFromTo.relatesInSteps {α : Type u_1} {r : ααProp} {a b : α} {chain : List α} {n : } (hc : IsChainFromTo r chain a b) (hlen : chain.length = n + 1) :

    If there is an r-chain of n + 1 elements from a to b, then a and b are related to each other in n steps.

    theorem Relation.relatesInSteps_iff_exists_isChainFromTo {α : Type u_1} {r : ααProp} {a b : α} {n : } :
    RelatesInSteps r a b n ∃ (chain : List α), List.IsChainFromTo r chain a b chain.length = n + 1

    a and b are related in n steps exactly when there is an r-chain of n + 1 elements from a to b.

    RelatesWithinSteps - only requires an upper bound on the number of steps #

    def Relation.RelatesWithinSteps {α : Type u_1} (r : ααProp) (a b : α) (n : ) :

    RelatesWithinSteps is a variant of RelatesInSteps that allows for a loose bound. It states that a relates to b in at most n steps.

    Equations
    Instances For
      theorem Relation.RelatesWithinSteps.of_relatesInSteps {α : Type u_1} {r : ααProp} {a b : α} {n : } (h : RelatesInSteps r a b n) :

      RelatesInSteps implies RelatesWithinSteps with the same bound.

      theorem Relation.RelatesWithinSteps.refl {α : Type u_1} {r : ααProp} (a : α) :
      theorem Relation.RelatesWithinSteps.single {α : Type u_1} {r : ααProp} {a b : α} (h : r a b) :
      theorem Relation.RelatesWithinSteps.zero {α : Type u_1} {r : ααProp} {a b : α} (h : RelatesWithinSteps r a b 0) :
      a = b
      @[simp]
      theorem Relation.RelatesWithinSteps.zero_iff {α : Type u_1} {r : ααProp} {a b : α} :
      theorem Relation.RelatesWithinSteps.trans {α : Type u_1} {r : ααProp} {a b c : α} {n₁ n₂ : } (h₁ : RelatesWithinSteps r a b n₁) (h₂ : RelatesWithinSteps r b c n₂) :
      RelatesWithinSteps r a c (n₁ + n₂)

      Transitivity of RelatesWithinSteps in the sum of the step bounds.

      theorem Relation.RelatesWithinSteps.mono {α : Type u_1} {r : ααProp} {a b : α} :
      Monotone fun (x : ) => RelatesWithinSteps r a b x

      If two elements a and b are related in at most n₁ steps in the relation r and n₁ ≤ n₂, then they are also related in at most n₂ steps.

      theorem Relation.RelatesWithinSteps.apply_le_apply_add {α : Type u_1} {r : ααProp} {a b : α} {m : } (hevals : RelatesWithinSteps r a b m) (h : α) (h_step : ∀ (a b : α), r a bh b h a + 1) :
      h b h a + m

      If h : α → ℕ increases by at most 1 on each step of r, then the value of h at the output is at most h at the input plus the step bound.

      theorem Relation.RelatesWithinSteps.map {α : Type u_2} {α' : Type u_3} {r : ααProp} {r' : α'α'Prop} (g : αα') (hg : ∀ (a b : α), r a br' (g a) (g b)) {a b : α} {n : } (h : RelatesWithinSteps r a b n) :
      RelatesWithinSteps r' (g a) (g b) n

      If g is a homomorphism from r to r' (i.e., it preserves the reduction relation), then RelatesWithinSteps is preserved under g.

      Reachability under a bound on the number of reachable elements #

      theorem Relation.ReflTransGen.relatesInSteps_lt_encard {α : Type u_1} {r : ααProp} {a b : α} (h : ReflTransGen r a b) :
      ∃ (n : ), RelatesInSteps r a b n n < {x : α | ReflTransGen r a x}.encard

      A more precise version of ReflTransGen.relatesInSteps: if b is reachable from a, then it is related to a in fewer steps than there are elements reachable from a. Note that this cardinality is an ℕ∞, and if it is infinite, no bound on the number of steps is stated.