Composition, transitivity, and antisymmetry of List.Forall₂ #
List.Forall₂ R relates lists of equal length pointwise. It composes pointwise
(List.forall₂_comp_iff), so it inherits transitivity and antisymmetry from R, as
List.SublistForall₂ does in Mathlib/Data/List/Forall2.lean; with R := (· ≤ ·) this is the
pointwise order on lists of equal length, which the lexicographic order refines
(List.Forall₂.le, List.Forall₂.lt_of_ne), as Pi.toLex_monotone and Pi.toLex_strictMono
say of Pi.Lex; the pointwise witnesses of Phonology/Tone/Register.lean lift to the
lexicographic order this way. [UPSTREAM] candidates for that file, beside
List.SublistForall₂.is_refl and List.SublistForall₂.is_trans.
Main results #
List.forall₂_comp_iff:Forall₂ (R ∘r S)is the pointwise composite ofForall₂ RandForall₂ S.List.Forall₂.trans,List.Forall₂.antisymm, and theStd.Refl,IsTrans,Std.Antisymminstances onForall₂ R.List.Forall₂.le,List.Forall₂.lt_of_ne: lists ordered pointwise are ordered lexicographically.List.decidableForall₂: aDecidable (Forall₂ R l₁ l₂)instance thatdecidecan evaluate.
Implementation notes #
Batteries decides Forall₂ through List.all₂, whose body it stopped exposing to other modules
in batteries#2006, so decide gets stuck on it. List.decidableForall₂ takes priority over that
instance; remove it once Batteries exposes List.all₂ again.
Forall₂ for a composite relation is the pointwise composite of the two Forall₂s.
Decidability #
Forall₂ R decided by structural recursion on both lists, so that decide evaluates it
outside this module.
Equations
- [].decidableForall₂ [] = isTrue ⋯
- [].decidableForall₂ (head :: tail) = isFalse ⋯
- (head :: tail).decidableForall₂ [] = isFalse ⋯
- (a :: l₁).decidableForall₂ (b :: l₂) = decidable_of_iff (R a b ∧ List.Forall₂ R l₁ l₂) ⋯
The lexicographic order refines the pointwise order #
Lists ordered pointwise are ordered lexicographically, the list form of
Pi.toLex_monotone.
Distinct lists ordered pointwise are strictly ordered lexicographically, the list form of
Pi.toLex_strictMono.