I am currently trying to define a finset (of a collection of finite images of some function).
More specifically, given a fixed mapping between the maximal chains of a partially ordered set (of which there are finitely many) to a list in another partially ordered set, I want to define a finset of these image lists. The final goal is to use Finset.sort to order the lists lexicographically. There are some lemmas and definitions that I have left in the full code at the bottom.
Given two partial orders P and A, where P is finite, we can define a map edgeLabeling from the edges of P to A. (a ⋖ b means a < b and there is no other element x such that a < x < b)
variable {P : Type*} [PartialOrder P] [Fintype P]
def edges (P : Type*) [PartialOrder P] : Set (P × P) := {(a, b) | a ⋖ b }
abbrev edgeLabeling (P A : Type*) [PartialOrder P] := edges P → A
Then, given some edge labeling, we can map the maximal chains of P to lists in A. (we have that maximalChains P is of type Finset (List P); and that edgePairs m is the list of the pairs of adjacent elements in the chain m)
abbrev chain (L : List P) : Prop := List.Chain' (· < ·) L
abbrev maximal_chain (L: List P) : Prop := chain L ∧ ∀ L' : List P, chain L' -> List.Sublist L L' -> L = L'
abbrev maximalChains (P : Type*) [PartialOrder P] [Fintype P] : Finset (List P) := Set.toFinset { L | maximal_chain L }
def mapMaxChain (l : edgeLabeling P A) (m : maximalChains P) : List A := List.map (fun e => l e) <| edgePairs m
Finally, what I want to do is to define the following as a Finset.
abbrev maxAChains (l : edgeLabeling P A) : Finset (List A) := Set.toFinset {mapMaxChain l L | L : maximalChains P}
Here is the full code, I apologise if it is convoluted:
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Fintype.List
import Mathlib.Data.Set.Finite
import Mathlib.Order.Cover
noncomputable section
open List Classical
namespace List
variable {P : Type*} [PartialOrder P] [Fintype P]
def adjPairs (α : Type*) : List α → List (α × α)
| [] => []
| _ :: [] => []
| a :: b :: l => ((a, b) : α × α) :: (b :: l).adjPairs
lemma adjPairs_cons {a b :α} {L : List α} : (a,b) ∈ (a::b::L).adjPairs:= by sorry
lemma adjPairs_tail {h a b : α} {tail : List α} : (a,b) ∈ tail.adjPairs → (a,b) ∈ (h::tail).adjPairs:= by sorry
def adjEPairs (L : List α) : List ({e : α × α | e ∈ L.adjPairs}) := match L with
| [] => []
| _ :: [] => []
| a :: b :: l => ⟨(a, b), List.adjPairs_cons⟩ :: (List.map (fun e => ⟨e.val, List.adjPairs_tail e.prop ⟩) <| List.adjEPairs (b :: l))
def edges (P : Type*) [PartialOrder P] : Set (P × P) := {(a, b) | a ⋖ b }
abbrev edgeLabeling (P A : Type*) [PartialOrder P] := edges P → A
abbrev chain (L : List P) : Prop := List.Chain' (· < ·) L
abbrev maximal_chain (L: List P) : Prop := chain L ∧ ∀ L' : List P, chain L' -> List.Sublist L L' -> L = L'
lemma chain_nodup {L : List P} (h : chain L) : L.Nodup := by sorry
lemma max_chain_mem_edge {P : Type*} [PartialOrder P] {L: List P} {e: P × P} : maximal_chain L → e ∈ L.adjPairs → e ∈ edges P:= by sorry
instance : Fintype (Set.Elem { L : List P | L.Nodup }) := inferInstanceAs (Fintype { L : List P // L.Nodup })
instance : Fintype { L : List P | maximal_chain L } := Set.fintypeSubset { L : List P | L.Nodup} fun _ h ↦ Set.mem_setOf_eq.mpr (chain_nodup (Set.mem_setOf_eq.mp h).1)
abbrev maximalChains (P : Type*) [PartialOrder P] [Fintype P] : Finset (List P) := Set.toFinset { L | maximal_chain L }
def edgePairs {P : Type*} [PartialOrder P] [Fintype P] (L : maximalChains P) : List (edges P) :=
List.map (fun e => ⟨e.val, max_chain_mem_edge (Set.mem_setOf_eq.mp (Set.mem_toFinset.mp L.prop)) e.prop⟩) <| L.val.adjEPairs
def mapMaxChain (l : edgeLabeling P A) (m : maximalChains P) : List A := List.map (fun e => l e) <| edgePairs m
abbrev maxAChains (l : edgeLabeling P A) : Finset (List A) := Set.toFinset {mapMaxChain l L | L : maximalChains P}
map
andset_map
? They just seem to be unnecessary renamings of→
andList.map
. $\endgroup$FinSet
need to be finite, but your set is infinite. Your set is the forward image underList.map m
of all lists in List α. There are infinitely many such lists. Even if alpha is finite (even if alpha is Unit), there are infinitely many such lists, at least one for each length. $\endgroup$set_map m A
you can just writeA.map m
, orList.map m a
. $\endgroup$