Skip to content

Commit 2858497

Browse files
committed
minor sorting network progress
1 parent 581cc9c commit 2858497

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

RecMath/SortingNetwork.lean

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,44 @@ def extend_fin.equiv {n : Nat} : Fin n ≃ {x : Fin (n + 1) // x < n } where
345345
left_inv _ := rfl
346346
right_inv _ := rfl
347347

348+
theorem finset_lt_exclusion (n: ℕ) (S: Finset ℕ) (ssh: S ⊂ Finset.range n) (x: ℕ) : (∀ s ∈ S, s < x) -> (S.card <= x) := by
349+
intro h
350+
induction n with
351+
| zero =>
352+
-- rw [Finset.range_zero] at ssh
353+
grind only [= Finset.subset_iff, Finset.ssubset_iff_subset_ne, usr Finset.card_ne_zero_of_mem,
354+
= Finset.mem_range]
355+
-- Strict subset of a singleton is empty
356+
-- So S.card is 0
357+
-- All natural numbers are greater than or equal to zero
358+
| succ n hn =>
359+
-- First case 1 ∉ S
360+
-- Let T = {s ∈ S, s - 1}
361+
-- Then, T < Finset.range (n - 1)
362+
-- For any t ∈ T,
363+
-- There exists an s ∈ S such that t = s - 1, so t < x - 1
364+
-- Then applying the inductive hypothesis, T.card <= x - 1, so S.card <= x
365+
366+
-- Second case, 1 ∈ S,
367+
-- Let T = {s ∈ S / {1}, s - 1}
368+
-- Then, T < Finset.range (n - 1)
369+
-- For any t ∈ T,
370+
-- There exists an s ∈ S such that t = s - 1, so t < x - 1
371+
-- Then applying the inductive hypothesis, T.card = S.card - 1 <= x - 1, so S.card <= x
372+
sorry
373+
348374
theorem monotone_perm_eq_one {n : Nat} {p : Equiv.Perm (Fin n)} (mono : Monotone p) : p = 1 := by
349375
-- unfold Monotone at mono
350376
-- Induct and try to transfer proofs using MonotoneOn then expand the set
351377
induction n with
352378
| zero => exact Subsingleton.allEq p 1
353379
| succ n h =>
354-
specialize @h 1
355-
change p = Equiv.refl _
356-
rw [<- Equiv.Perm.extendDomain_refl extend_fin.equiv]
380+
ext i
381+
-- specialize @h 1
382+
simp? [Equiv.Perm.coe_one]
383+
have p_n_sub_one_eq_n_sub_one : p (Fin.mk (n - 1) (by omega)) = n - 1 := by sorry
384+
let q (x: (Fin n)): Fin (n + 1) := p (Fin.mk x (by omega))
385+
357386
sorry
358387

359388
-- The basic idea that if a comparison network can sort all permuataions, then it can sort anything
@@ -404,11 +433,24 @@ theorem ComparisonNetwork.zero_one_principle (net : ComparisonNetwork n) :
404433
· order
405434
simp [<- this]
406435

407-
have : f (net.apply a j) ≠ f (net.apply a i) := by
436+
set b := net.apply a
437+
438+
have : f (b j) ≠ f (b i) := by
408439
unfold f
409440
simp
410441
push_neg
411442
simp [f, Bool.le_iff_imp] at fswap
443+
rw [Classical.or_iff_not_imp_left]
444+
intro h
445+
push_neg at h
446+
447+
-- let b := net.apply a
448+
have h1 (a b : Prop) : a ∧ b <-> ¬(¬a ∨ ¬b) := by tauto
449+
have h2 (a b : Prop) : ¬(¬a ∨ ¬b) <-> ¬(a -> ¬b) := by tauto
450+
rw [h1, h2]
451+
452+
453+
412454
sorry
413455

414456
order

0 commit comments

Comments
 (0)