Skip to content

Commit e4a8003

Browse files
committed
Continue graph morphism surjectivity
1 parent 7505fd8 commit e4a8003

1 file changed

Lines changed: 98 additions & 32 deletions

File tree

TraceTheoryLean/Main.lean

Lines changed: 98 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ def toTrace : FreeMonoid α →* I.Trace where
12291229
map_one' := rfl
12301230
map_mul' _ _ := rfl
12311231

1232-
structure DependencyMorphism (M : Type) [Monoid M] where
1232+
structure DependencyMorphism (M : Type*) [Monoid M] where
12331233
hom : FreeMonoid α →* M
12341234
surj : Function.Surjective hom
12351235
prop1 : ∀ s, hom s = hom 1 → s = 1
@@ -2052,8 +2052,9 @@ theorem has_max_vertex [Nonempty V] (G : D.DependenceGraph V) : ∃ v, ∀ u, ¬
20522052
simp [DependenceGraph.reverse] at hv
20532053
exact ⟨v, hv⟩
20542054

2055-
theorem Relation.transGen_sub {α : Type*} {p q : α → α → Prop} (h : ∀ x y, p x y → q x y) :
2056-
(∀ x y, Relation.TransGen p x y → Relation.TransGen q x y) := by
2055+
theorem Relation.transGen_sub_iso {α β : Type*} (p : α → α → Prop) (q : β → β → Prop) (f : α → β)
2056+
(h : ∀ x y, p x y → q (f x) (f y)) :
2057+
(∀ x y, Relation.TransGen p x y → Relation.TransGen q (f x) (f y)) := by
20572058
intro x y hpt
20582059
induction hpt with
20592060
| single hp =>
@@ -2063,22 +2064,31 @@ theorem Relation.transGen_sub {α : Type*} {p q : α → α → Prop} (h : ∀ x
20632064
rename_i w y
20642065
exact Relation.TransGen.trans hqt (Relation.TransGen.single (h w y hpw))
20652066

2067+
theorem Relation.transGen_sub {α : Type*} {p q : α → α → Prop} (h : ∀ x y, p x y → q x y) :
2068+
(∀ x y, Relation.TransGen p x y → Relation.TransGen q x y) := by
2069+
apply Relation.transGen_sub_iso
2070+
exact h
2071+
20662072
def omit_vertex (G : D.DependenceGraph V) (v : V) : D.DependenceGraph {x // x ≠ v} where
20672073
adj := fun u v => G.adj u v
20682074
φ := fun v => G.φ v
20692075
acyclic := by
20702076
intro ⟨x, hx⟩ h
2071-
simp at h
2072-
have h_sub : ∀ x y, (fun u v => G.adj u v) x y → G.adj x y := by simp
2073-
have h_id := Relation.transGen_sub (h_sub) x x
2074-
apply G.acyclic x
2075-
apply h_id
2076-
sorry
2077+
apply Relation.transGen_sub_iso _ G.adj (fun ⟨x, hx⟩ => x) at h
2078+
· simp [G.acyclic] at h
2079+
· simp
20772080
dep := by
20782081
intro ⟨u, hu⟩ ⟨v, hv⟩
20792082
simp
20802083
exact G.dep u v
20812084

2085+
def omit_vertex_rep (G : D.DepGraphRep) (v : G.V) : D.DepGraphRep where
2086+
V := {x // x ≠ v}
2087+
fintypeV := by
2088+
--exact Fintype.ofSurjective ?_
2089+
sorry
2090+
graph := omit_vertex G.graph v
2091+
20822092
/-
20832093
theorem _induction_card {P : ∀ (V : Type u) [Fintype V], D.DependenceGraph V → Prop}
20842094
(h_empty : ∀ (V : Type u) [Fintype V] (G : D.DependenceGraph V), Fintype.card V = 0 → P V G)
@@ -2148,13 +2158,13 @@ theorem omit_induction {P : ∀ (V : Type u) [Fintype V], D.DependenceGraph V
21482158
def card : D.DepGraphMonoid → ℕ :=
21492159
Quotient.lift (fun GR : DepGraphRep => @Fintype.card GR.V GR.fintypeV) (by
21502160
intro a b ⟨φ⟩
2151-
have := a.fintypeV
2152-
have := b.fintypeV
21532161
simp
2154-
exact Fintype.card_congr φ.map
2155-
sorry
2162+
exact @Fintype.card_congr a.V b.V a.fintypeV b.fintypeV φ.map
21562163
)
21572164

2165+
lemma card_eq_card_memV (Γ : D.DepGraphMonoid) : Γ.card = @Fintype.card Γ.out.V Γ.out.fintypeV := by
2166+
rw [card, show Γ = ⟦Γ.out⟧ by simp, Quotient.lift_mk, Quotient.out_eq]
2167+
21582168
theorem toDepGraph_surj (Γ : D.DepGraphMonoid) : ∃ s : FreeMonoid α, toDepGraph s = Γ := by
21592169
induction h : card Γ generalizing Γ with
21602170
| zero =>
@@ -2165,27 +2175,41 @@ theorem toDepGraph_surj (Γ : D.DepGraphMonoid) : ∃ s : FreeMonoid α, toDepGr
21652175
apply Quotient.sound
21662176
refine ⟨?_, ?_, ?_⟩
21672177
all_goals simp
2178+
--rw [card_eq_card_memV] at h
21682179
rw [card, show Γ = ⟦Γ.out⟧ by simp, Quotient.lift_mk] at h
2169-
calc
2170-
Fin 0 ≃ Empty := by
2171-
exact ⟨Fin.elim0,
2172-
Empty.elim,
2173-
by simp [Function.LeftInverse],
2174-
by simp [Function.RightInverse, Function.LeftInverse]⟩
2175-
Empty ≃ (Quotient.out Γ).V := by
2176-
have := (Quotient.out Γ).fintypeV
2177-
-- have := Fintype.cardEqZeroEquivEquivEmpty h
2178-
refine ⟨Empty.elim, ?_, by simp [Function.LeftInverse], ?_⟩
2179-
· sorry
2180-
· sorry
2181-
-- rw [@Fintype.card_eq_zero_iff] at h
2182-
-- rw [Fintype.cardEqZeroEquivEquivEmpty] at h
2180+
apply Iff.mp (@Fintype.card_eq_zero_iff (Quotient.out Γ).V (Quotient.out Γ).fintypeV) at h
2181+
apply Equiv.equivOfIsEmpty
21832182
| succ n ih =>
2184-
rw [show Γ = ⟦Γ.out⟧ by simp]
2185-
-- have ⟨v, hv⟩ := has_max_vertex Γ.out.graph
2186-
-- have H := omit_vertex Γ.out.graph v
2187-
-- (apply ih to H, and prove [appending the respective symbol to H's string] →* Γ.out.graph)
2188-
sorry
2183+
let G := Γ.out
2184+
have hG : G = Γ.out := by rfl
2185+
rw [show Γ = ⟦G⟧ by simp [hG]] at h ⊢
2186+
have h_vNe : Nonempty G.V := by
2187+
have : @Fintype.card G.V G.fintypeV = n + 1 := by
2188+
simp [card] at h
2189+
exact h
2190+
have : @Fintype.card G.V G.fintypeV > 0 := by simp [this]
2191+
exact (@Fintype.card_pos_iff G.V G.fintypeV).mp this
2192+
have h_vFt := G.fintypeV
2193+
have ⟨v, hv⟩ := has_max_vertex G.graph
2194+
have h_voFt : Fintype { x // x ≠ v } := by sorry -- simp []
2195+
replace ih := ih (⟦toRep (omit_vertex G.graph v)⟧)
2196+
have h_Hn : card ⟦toRep (omit_vertex G.graph v)⟧ = n := by
2197+
simp [card, toRep]
2198+
rw [card_eq_card_memV, Quotient.out_eq, <- hG] at h
2199+
-- rw [h]
2200+
sorry
2201+
have ⟨s, hs⟩ := ih h_Hn
2202+
use s * FreeMonoid.of (G.graph.φ v)
2203+
apply Quotient.sound
2204+
simp [toRep, toDepGraphIndiv]
2205+
refine ⟨?_, ?_, ?_⟩
2206+
· refine ⟨?_, ?_, ?_, ?_⟩
2207+
· sorry
2208+
· sorry
2209+
· sorry
2210+
· sorry
2211+
· sorry
2212+
· sorry
21892213

21902214
/-
21912215
theorem max_vertex_induction {V} {motive : Type u → D.DependenceGraph V → Prop} (nil : motive (∅ : Set V) emptyGraph)
@@ -2212,6 +2236,48 @@ theorem max_vertex_induction {V} {motive : Type u → D.DependenceGraph V → Pr
22122236
exact this l [] nil
22132237
-/
22142238

2239+
def toDependencyMorphism [DecidableEq α] : D.independency.DependencyMorphism (D.DepGraphMonoid) where
2240+
hom := toDepGraph
2241+
surj := toDepGraph_surj
2242+
prop1 := by
2243+
intro s h
2244+
-- simp at h
2245+
simp [toDepGraph, toRep] at h
2246+
have : List.length s = @List.length α [] := by
2247+
simp [h]
2248+
2249+
replace h : (toDepGraph s).card = (toDepGraph 1).card := by simp [h]
2250+
have : (I.toTrace) s = (I.toTrace) 1 := h
2251+
simp [toTrace] at this
2252+
have hrel : I.trace_equiv s [] := Quotient.exact this
2253+
have hlen : s.length = ([] : List α).length := I.trace_equiv_length hrel
2254+
cases s with
2255+
| h0 => rfl
2256+
| ih a s' => simp at hlen
2257+
prop2 := by
2258+
intro a b h
2259+
simp
2260+
apply Quotient.sound
2261+
refine ⟨?_, ?_, ?_⟩
2262+
· refine ⟨?_, ?_, ?_, ?_⟩
2263+
· exact fun v => v --
2264+
· exact fun v => v --
2265+
· simp [Function.LeftInverse]
2266+
· simp [Function.RightInverse, Function.LeftInverse]
2267+
· simp [toRep, DepGraphRep.mul]
2268+
intro v
2269+
· sorry
2270+
prop3 := by
2271+
intro a u v h
2272+
have hrel : I.trace_equiv ((u.toList ++ [a]).cancelRight a) (v.cancelRight a) :=
2273+
I.cancelRight_preserves_congruence a (Quotient.exact h)
2274+
simp at hrel
2275+
exact Quotient.sound hrel
2276+
prop4 := by
2277+
intro a b u v hne h
2278+
have hrel : I.trace_equiv (u.toList ++ [a]) (v.toList ++ [b]) := Quotient.exact h
2279+
exact (I.tail_lemma u v a b hrel hne).left
2280+
22152281
end DepGraphMonoid
22162282

22172283
end Dependency

0 commit comments

Comments
 (0)