def BethTreeCoverage {α : Type u} (T : BethTree α) :
Coverage {l : SnocList α // T.tree_node l} where
covers w S := IsBar T w.1 (nodeBar S)
maximal := by
intro ⟨l, hl⟩ f hl' hpaths
refine ⟨0, ?_⟩
simp only [initial, SnocList.append_nil, nodeBar, maximal_sieve, Set.mem_setOf_eq]
exact ⟨hl', le_refl _⟩
stability := by
intro ⟨ps, hps⟩ ⟨qs, hqs⟩ S bar_in_S p_le_q f_qs in_T f_in_T
haveI : Nonempty α := T.nonempty
obtain ⟨f_ps, n_ps, rfl⟩ := le_init ps qs p_le_q
let f_total (i : ℕ) := if h : i < n_ps then f_ps i else f_qs (i - n_ps)α : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps)
have f_total_low : ∀ i < n_ps, f_total i = f_ps i := fun i hi => byα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) simp [f_total, hi]
have f_total_high : ∀ i, f_total (n_ps + i) = f_qs i := fun i => byα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i ⊢ f_total (n_ps + i) = f_qs i
simp [f_total, show ¬ (n_ps + i < n_ps) from Nat.not_lt_of_le (Nat.le_add_right _ _)]
have h_total_init : ∀ m ≤ n_ps, initial f_total m = initial f_ps m := fun m hm =>
initial_eq_of_agree (fun i hi => f_total_low i (Nat.lt_of_lt_of_le hi hm))α : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
have h_total_split : initial f_total n_ps = initial f_ps n_ps :=
h_total_init n_ps (le_refl _)α : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
have hpath_total : ∀ n, T.tree_node (ps ++ initial f_total n) := by
intro nα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
by_cases h : n ≤ n_psposα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
·posα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i rw [h_total_init n h]posα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
exact T.prefix_closed' (SnocList.le_of_initial_le ps h) in_T
·negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i push Not at hnegα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le (Nat.le_of_lt h)negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
rw [initial_add, ← SnocList.append_assoc, h_total_split,
initial_eq_of_agree (fun i _ => f_total_high i)]negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
exact f_in_T k
obtain ⟨m, hm_bar⟩ := bar_in_S f_total hps hpath_totalα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
obtain ⟨hm_node, hm_mem⟩ := hm_barα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
by_cases hmle : n_ps ≤ mposα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
·posα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmleposα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
refine ⟨k, ?_⟩posα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
simp only [nodeBar, pullback, Set.mem_setOf_eq]posα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
have heq : ps ++ initial f_total (n_ps + k) =
ps ++ initial f_ps n_ps ++ initial f_qs k := by
rw [initial_add, ← SnocList.append_assoc, h_total_split,
initial_eq_of_agree (fun i _ => f_total_high i)]
have hm_node' : T.tree_node (ps ++ initial f_ps n_ps ++ initial f_qs k) := heq ▸ hm_nodeposα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
have helem : (⟨ps ++ initial f_total (n_ps + k), hm_node⟩ : {l : SnocList α // T.tree_node l}) =
⟨ps ++ initial f_ps n_ps ++ initial f_qs k, hm_node'⟩ := Subtype.ext heqposα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
exact ⟨hm_node', helem ▸ hm_mem, SnocList.is_prefix_append _ _⟩
·negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i push Not at hmlenegα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
refine ⟨0, ?_⟩negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
simp only [initial, SnocList.append_nil, nodeBar, pullback, Set.mem_setOf_eq]negα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
have hm_le : m ≤ n_ps := Nat.le_of_lt hmlenegα : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i
have hle_qs : ps ++ initial f_total m ≤ ps ++ initial f_ps n_ps := by
rw [h_total_init m hm_le]α : Type u
f_total : ℕ → α := fun i => if h : i < n_ps then f_ps i else f_qs (i - n_ps) f_total_low : ∀ i < n_ps, f_total i = f_ps i f_total_high : ∀ (i : ℕ), f_total (n_ps + i) = f_qs i ; exact SnocList.le_of_initial_le ps hm_le
exact ⟨hqs, S.upward_closed hm_mem hle_qs, le_refl _⟩
transitive := by
intro ⟨l, hl⟩ U V bar_in_U h_UV f in_T f_in_T
obtain ⟨n1, hn1_bar⟩ := bar_in_U f hl f_in_T
obtain ⟨hn1_node, hn1_mem⟩ := hn1_bar
let q := l ++ initial f n1
let f_tail (i : ℕ) := f (n1 + i)α : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
have f_tail_in_T : ∀ n, T.tree_node (q ++ initial f_tail n) := fun n => byα : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
simpa [q, f_tail, initial_add, SnocList.append_assoc] using f_in_T (n1 + n)
have h_cov_q := h_UV ⟨⟨q, hn1_node⟩, hn1_mem⟩α : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
obtain ⟨n2, hn2_bar⟩ := h_cov_q f_tail hn1_node f_tail_in_Tα : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
obtain ⟨hn2_node, hn2_mem⟩ := hn2_barα : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
simp only [pullback, Set.mem_setOf_eq] at hn2_memα : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
refine ⟨n1 + n2, ?_⟩α : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
simp only [nodeBar]α : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
have heq : q ++ initial f_tail n2 = l ++ initial f (n1 + n2) := by
simp [q, f_tail, initial_add, SnocList.append_assoc]
have hn2_node' : T.tree_node (l ++ initial f (n1 + n2)) := heq ▸ hn2_nodeα : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
have helem : (⟨q ++ initial f_tail n2, hn2_node⟩ : {l : SnocList α // T.tree_node l}) =
⟨l ++ initial f (n1 + n2), hn2_node'⟩ := Subtype.ext heqα : Type u
f_tail : ℕ → α := fun i => f (n1 + i)
exact ⟨hn2_node', helem ▸ hn2_mem.1⟩