Module docstring
{"# The cartesian product of lists
Main definitions
List.pi: Cartesian product of lists indexed by a list. "}
{"# The cartesian product of lists
List.pi: Cartesian product of lists indexed by a list.
"}List.Pi.nil
definition
(α : ι → Sort*) : (∀ i ∈ ([] : List ι), α i)
/-- Given `α : ι → Sort*`, `Pi.nil α` is the trivial dependent function out of the empty list. -/
def nil (α : ι → Sort*) : (∀ i ∈ ([] : List ι), α i) :=
nofun
List.Pi.head
definition
(f : ∀ j ∈ i :: l, α j) : α i
/-- Given `f` a function whose domain is `i :: l`, get its value at `i`. -/
def head (f : ∀ j ∈ i :: l, α j) : α i :=
f i mem_cons_self
List.Pi.tail
definition
(f : ∀ j ∈ i :: l, α j) : ∀ j ∈ l, α j
/-- Given `f` a function whose domain is `i :: l`, produce a function whose domain
is restricted to `l`. -/
def tail (f : ∀ j ∈ i :: l, α j) : ∀ j ∈ l, α j :=
fun j hj ↦ f j (mem_cons_of_mem _ hj)
List.Pi.cons
definition
(a : α i) (f : ∀ j ∈ l, α j) : ∀ j ∈ i :: l, α j
/-- Given `α : ι → Sort*`, a list `l` and a term `i`, as well as a term `a : α i` and a
function `f` such that `f j : α j` for all `j` in `l`, `Pi.cons a f` is a function `g` such
that `g k : α k` for all `k` in `i :: l`. -/
def cons (a : α i) (f : ∀ j ∈ l, α j) : ∀ j ∈ i :: l, α j :=
Multiset.Pi.cons (α := ι) l _ a f
List.Pi.cons_def
theorem
(a : α i) (f : ∀ j ∈ l, α j) :
cons _ _ a f = fun j hj ↦ if h : j = i then h.symm.rec a else f j <| (mem_cons.1 hj).resolve_left h
lemma cons_def (a : α i) (f : ∀ j ∈ l, α j) : cons _ _ a f =
fun j hj ↦ if h : j = i then h.symm.rec a else f j <| (mem_cons.1 hj).resolve_left h :=
rfl
Multiset.Pi.cons_coe
theorem
{l : List ι} (a : α i) (f : ∀ j ∈ l, α j) : Multiset.Pi.cons l _ a f = cons _ _ a f
@[simp] lemma _root_.Multiset.Pi.cons_coe {l : List ι} (a : α i) (f : ∀ j ∈ l, α j) :
Multiset.Pi.cons l _ a f = cons _ _ a f :=
rfl
List.Pi.cons_eta
theorem
(f : ∀ j ∈ i :: l, α j) : cons _ _ (head f) (tail f) = f
@[simp] lemma cons_eta (f : ∀ j ∈ i :: l, α j) :
cons _ _ (head f) (tail f) = f :=
Multiset.Pi.cons_eta (α := ι) (m := l) f
List.Pi.cons_map
theorem
(a : α i) (f : ∀ j ∈ l, α j) {α' : ι → Sort*} (φ : ∀ ⦃j⦄, α j → α' j) :
cons _ _ (φ a) (fun j hj ↦ φ (f j hj)) = (fun j hj ↦ φ ((cons _ _ a f) j hj))
lemma cons_map (a : α i) (f : ∀ j ∈ l, α j)
{α' : ι → Sort*} (φ : ∀ ⦃j⦄, α j → α' j) :
cons _ _ (φ a) (fun j hj ↦ φ (f j hj)) = (fun j hj ↦ φ ((cons _ _ a f) j hj)) :=
Multiset.Pi.cons_map _ _ _
List.Pi.forall_rel_cons_ext
theorem
{r : ∀ ⦃i⦄, α i → α i → Prop} {a₁ a₂ : α i} {f₁ f₂ : ∀ j ∈ l, α j} (ha : r a₁ a₂)
(hf : ∀ (i : ι) (hi : i ∈ l), r (f₁ i hi) (f₂ i hi)) : ∀ j hj, r (cons _ _ a₁ f₁ j hj) (cons _ _ a₂ f₂ j hj)
lemma forall_rel_cons_ext {r : ∀ ⦃i⦄, α i → α i → Prop} {a₁ a₂ : α i} {f₁ f₂ : ∀ j ∈ l, α j}
(ha : r a₁ a₂) (hf : ∀ (i : ι) (hi : i ∈ l), r (f₁ i hi) (f₂ i hi)) :
∀ j hj, r (cons _ _ a₁ f₁ j hj) (cons _ _ a₂ f₂ j hj) :=
Multiset.Pi.forall_rel_cons_ext (α := ι) (m := l) ha hf
List.pi
definition
: ∀ l : List ι, (∀ i, List (α i)) → List (∀ i, i ∈ l → α i)
List.pi_nil
theorem
(t : ∀ i, List (α i)) : pi [] t = [Pi.nil α]
List.pi_cons
theorem
(i : ι) (l : List ι) (t : ∀ j, List (α j)) : pi (i :: l) t = ((t i).flatMap fun b ↦ (pi l t).map <| Pi.cons _ _ b)
Multiset.pi_coe
theorem
(l : List ι) (fs : ∀ i, List (α i)) : (l : Multiset ι).pi (fs ·) = (↑(pi l fs) : Multiset (∀ i ∈ l, α i))
lemma _root_.Multiset.pi_coe (l : List ι) (fs : ∀ i, List (α i)) :
(l : Multiset ι).pi (fs ·) = (↑(pi l fs) : Multiset (∀ i ∈ l, α i)) := by
induction' l with i l ih
· change Multiset.pi 0 _ = _
simp only [Multiset.coe_singleton, Multiset.pi_zero, pi_nil, Multiset.singleton_inj]
ext i hi
simp at hi
· change Multiset.pi (i ::ₘ ↑l) _ = _
simp [ih, Multiset.coe_bind, - Multiset.cons_coe]
List.mem_pi
theorem
{l : List ι} (fs : ∀ i, List (α i)) : ∀ f : ∀ i ∈ l, α i, (f ∈ pi l fs) ↔ (∀ i (hi : i ∈ l), f i hi ∈ fs i)
lemma mem_pi {l : List ι} (fs : ∀ i, List (α i)) :
∀ f : ∀ i ∈ l, α i, (f ∈ pi l fs) ↔ (∀ i (hi : i ∈ l), f i hi ∈ fs i) := by
intros f
convert @Multiset.mem_pi ι _ α ↑l (fs ·) f using 1
rw [Multiset.pi_coe]
rfl