Imports
module public import Mathlib.ModelTheory.Arithmetic.Presburger.Semilinear.Defs public import Mathlib.Tactic.Ring public import Mathlib.LinearAlgebra.Dimension.Basic public import Pdl.Semantics public import Pdl.Vocab public import PdlTestFree.Paths
@[expose] public section

Semilinearity of L α for programs over a single atomic program

For a test-free program α the set L α = {n | L α n} of possible execution lengths of α (see PdlTestFree.Paths) is semilinear (L_isSemilinearSet); no assumption on the vocabulary is needed for this.

Conversely, not every semilinear X ⊆ ℕ is L α for a test-free α with voc α = {a}: a test-free α always admits some positive number of steps (L_pos), so ∅ and {0} are not of this form, and if it admits 0 steps then it admits all multiples of some p > 0 (L_zero), so e.g. {0, 2} is not of this form either. These are the only obstructions: exists_L_eq_iff characterises the sets L α as the nonempty semilinear sets X such that 0 ∈ X implies k * p ∈ X for all k, for some p > 0.

open Set Pointwise AddSubmonoidopen scoped Finset

L of compound programs as set operations

lemma L_atom_set (c : ℕ) : {n | L (·c) n} = {1} := c:ℕ⊢ {n | L (·c) n} = {1} c:ℕn:ℕ⊢ n ∈ {n | L (·c) n} ↔ n ∈ {1} All goals completed! 🐙lemma L_seq_set (α β : Program) : {n | L (α ;' β) n} = {n | L α n} + {n | L β n} := α:Programβ:Program⊢ {n | L (α;'β) n} = {n | L α n} + {n | L β n} α:Programβ:Programn:ℕ⊢ n ∈ {n | L (α;'β) n} ↔ n ∈ {n | L α n} + {n | L β n} α:Programβ:Programn:ℕ⊢ (∃ i j, L α i ∧ L β j ∧ n = i + j) ↔ ∃ x, L α x ∧ ∃ y, L β y ∧ x + y = n α:Programβ:Programn:ℕ⊢ (∃ i j, L α i ∧ L β j ∧ n = i + j) → ∃ x, L α x ∧ ∃ y, L β y ∧ x + y = nα:Programβ:Programn:ℕ⊢ (∃ x, L α x ∧ ∃ y, L β y ∧ x + y = n) → ∃ i j, L α i ∧ L β j ∧ n = i + j α:Programβ:Programn:ℕ⊢ (∃ i j, L α i ∧ L β j ∧ n = i + j) → ∃ x, L α x ∧ ∃ y, L β y ∧ x + y = n α:Programβ:Programi:ℕj:ℕhi:L α ihj:L β j⊢ ∃ x, L α x ∧ ∃ y, L β y ∧ x + y = i + j; All goals completed! 🐙 α:Programβ:Programn:ℕ⊢ (∃ x, L α x ∧ ∃ y, L β y ∧ x + y = n) → ∃ i j, L α i ∧ L β j ∧ n = i + j α:Programβ:Programi:ℕhi:L α ij:ℕhj:L β j⊢ ∃ i_1 j_1, L α i_1 ∧ L β j_1 ∧ i + j = i_1 + j_1; All goals completed! 🐙lemma L_union_set (α β : Program) : {n | L (α ⋓ β) n} = {n | L α n} ∪ {n | L β n} := α:Programβ:Program⊢ {n | L (α⋓β) n} = {n | L α n} ∪ {n | L β n} α:Programβ:Programn:ℕ⊢ n ∈ {n | L (α⋓β) n} ↔ n ∈ {n | L α n} ∪ {n | L β n} All goals completed! 🐙lemma L_star_set (α : Program) : {n | L (∗α) n} = (closure {n | L α n} : Set ℕ) := α:Program⊢ {n | L (∗α) n} = ↑(closure {n | L α n}) α:Programn:ℕ⊢ n ∈ {n | L (∗α) n} ↔ n ∈ ↑(closure {n | L α n}) α:Programn:ℕ⊢ (∃ l, (∀ i ∈ l, L α i) ∧ n = l.sum) ↔ n ∈ closure {n | L α n} α:Programn:ℕ⊢ (∃ l, (∀ i ∈ l, L α i) ∧ n = l.sum) → n ∈ closure {n | L α n}α:Programn:ℕ⊢ n ∈ closure {n | L α n} → ∃ l, (∀ i ∈ l, L α i) ∧ n = l.sum α:Programn:ℕ⊢ (∃ l, (∀ i ∈ l, L α i) ∧ n = l.sum) → n ∈ closure {n | L α n} α:Programl:List ℕhl:∀ i ∈ l, L α i⊢ l.sum ∈ closure {n | L α n} All goals completed! 🐙 α:Programn:ℕ⊢ n ∈ closure {n | L α n} → ∃ l, (∀ i ∈ l, L α i) ∧ n = l.sum α:Programn:ℕh:n ∈ closure {n | L α n}⊢ ∃ l, (∀ i ∈ l, L α i) ∧ n = l.sum α:Programl:List ℕhl:∀ y ∈ l, y ∈ {n | L α n}h:l.sum ∈ closure {n | L α n}⊢ ∃ l_1, (∀ i ∈ l_1, L α i) ∧ l.sum = l_1.sum All goals completed! 🐙

Every L α is semilinear

For any test-free program α the set L α is semilinear.

theorem L_isSemilinearSet : ∀ α : Program, α.testFree → IsSemilinearSet {n | L α n} a✝:Formulahα:(?'a✝).testFree⊢ IsSemilinearSet {n | L (?'a✝) n} a✝:Formulahα:(?'a✝).testFree⊢ IsSemilinearSet {n | L (?'a✝) n} All goals completed! 🐙 c:ℕx✝:(·c).testFree⊢ IsSemilinearSet {n | L (·c) n} c:ℕx✝:(·c).testFree⊢ IsSemilinearSet {n | L (·c) n} c:ℕx✝:(·c).testFree⊢ IsSemilinearSet {1} All goals completed! 🐙 α:Programβ:Programhαβ:(α;'β).testFree⊢ IsSemilinearSet {n | L (α;'β) n} α:Programβ:Programhαβ:(α;'β).testFree⊢ IsSemilinearSet {n | L (α;'β) n} α:Programβ:Programhαβ:α.testFree ∧ β.testFree⊢ IsSemilinearSet {n | L (α;'β) n} α:Programβ:Programhαβ:α.testFree ∧ β.testFree⊢ IsSemilinearSet ({n | L α n} + {n | L β n}) All goals completed! 🐙 α:Programβ:Programhαβ:(α⋓β).testFree⊢ IsSemilinearSet {n | L (α⋓β) n} α:Programβ:Programhαβ:(α⋓β).testFree⊢ IsSemilinearSet {n | L (α⋓β) n} α:Programβ:Programhαβ:α.testFree ∧ β.testFree⊢ IsSemilinearSet {n | L (α⋓β) n} α:Programβ:Programhαβ:α.testFree ∧ β.testFree⊢ IsSemilinearSet ({n | L α n} ∪ {n | L β n}) All goals completed! 🐙 α:Programhα:(∗α).testFree⊢ IsSemilinearSet {n | L (∗α) n} α:Programhα:(∗α).testFree⊢ IsSemilinearSet {n | L (∗α) n} α:Programhα:α.testFree⊢ IsSemilinearSet {n | L (∗α) n} α:Programhα:α.testFree⊢ IsSemilinearSet ↑(closure {n | L α n}) All goals completed! 🐙

Two obstructions to the converse

A test-free program admits some positive number of steps.

theorem L_pos : ∀ α : Program, α.testFree → ∃ n, 0 < n ∧ L α n a✝:Formulahα:(?'a✝).testFree⊢ ∃ n, 0 < n ∧ L (?'a✝) n a✝:Formulahα:(?'a✝).testFree⊢ ∃ n, 0 < n ∧ L (?'a✝) n All goals completed! 🐙 | ·_, _ => ⟨1, one_pos, rfl⟩ α:Programβ:Programhαβ:(α;'β).testFree⊢ ∃ n, 0 < n ∧ L (α;'β) n α:Programβ:Programhαβ:(α;'β).testFree⊢ ∃ n, 0 < n ∧ L (α;'β) n α:Programβ:Programhαβ:α.testFree ∧ β.testFree⊢ ∃ n, 0 < n ∧ L (α;'β) n α:Programβ:Programhαβ:α.testFree ∧ β.testFreei:ℕhi:0 < ihLi:L α i⊢ ∃ n, 0 < n ∧ L (α;'β) n α:Programβ:Programhαβ:α.testFree ∧ β.testFreei:ℕhi:0 < ihLi:L α ij:ℕhj:0 < jhLj:L β j⊢ ∃ n, 0 < n ∧ L (α;'β) n exact ⟨i + j, α:Programβ:Programhαβ:α.testFree ∧ β.testFreei:ℕhi:0 < ihLi:L α ij:ℕhj:0 < jhLj:L β j⊢ 0 < i + j All goals completed! 🐙, i, j, hLi, hLj, rfl⟩ α:Programβ:Programhαβ:(α⋓β).testFree⊢ ∃ n, 0 < n ∧ L (α⋓β) n α:Programβ:Programhαβ:(α⋓β).testFree⊢ ∃ n, 0 < n ∧ L (α⋓β) n α:Programβ:Programhαβ:α.testFree ∧ β.testFree⊢ ∃ n, 0 < n ∧ L (α⋓β) n α:Programβ:Programhαβ:α.testFree ∧ β.testFreei:ℕhi:0 < ihLi:L α i⊢ ∃ n, 0 < n ∧ L (α⋓β) n All goals completed! 🐙 α:Programhα:(∗α).testFree⊢ ∃ n, 0 < n ∧ L (∗α) n α:Programhα:(∗α).testFree⊢ ∃ n, 0 < n ∧ L (∗α) n α:Programhα:α.testFree⊢ ∃ n, 0 < n ∧ L (∗α) n α:Programhα:α.testFreei:ℕhi:0 < ihLi:L α i⊢ ∃ n, 0 < n ∧ L (∗α) n exact ⟨i, hi, [i], α:Programhα:α.testFreei:ℕhi:0 < ihLi:L α i⊢ ∀ i_1 ∈ [i], L α i_1 All goals completed! 🐙, α:Programhα:α.testFreei:ℕhi:0 < ihLi:L α i⊢ i = [i].sum All goals completed! 🐙⟩

If a test-free program admits 0 steps, then it admits all multiples of some p > 0.

theorem L_zero : ∀ α : Program, α.testFree → L α 0 → ∃ p, 0 < p ∧ ∀ k, L α (k * p) a✝:Formulahα:(?'a✝).testFreex✝:L (?'a✝) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (?'a✝) (k * p) a✝:Formulahα:(?'a✝).testFreex✝:L (?'a✝) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (?'a✝) (k * p) All goals completed! 🐙 c:ℕx✝:(·c).testFreeh0:L (·c) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (·c) (k * p) c:ℕx✝:(·c).testFreeh0:L (·c) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (·c) (k * p) All goals completed! 🐙 α:Programβ:Programhαβ:(α;'β).testFreeh0:L (α;'β) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α;'β) (k * p) α:Programβ:Programhαβ:(α;'β).testFreeh0:L (α;'β) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α;'β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L (α;'β) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α;'β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreei:ℕj:ℕhi:L α ihj:L β jhij:0 = i + j⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α;'β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreehi:L α 0hj:L β 0hij:0 = 0 + 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α;'β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreehi:L α 0hj:L β 0hij:0 = 0 + 0p:ℕhp:0 < phLp:∀ (k : ℕ), L α (k * p)⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α;'β) (k * p) exact ⟨p, hp, fun k => ⟨k * p, 0, hLp k, hj, α:Programβ:Programhαβ:α.testFree ∧ β.testFreehi:L α 0hj:L β 0hij:0 = 0 + 0p:ℕhp:0 < phLp:∀ (k : ℕ), L α (k * p)k:ℕ⊢ k * p = k * p + 0 All goals completed! 🐙⟩⟩ α:Programβ:Programhαβ:(α⋓β).testFreeh0:L (α⋓β) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) α:Programβ:Programhαβ:(α⋓β).testFreeh0:L (α⋓β) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L (α⋓β) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L α 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p)α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L β 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L α 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L α 0p:ℕhp:0 < phLp:∀ (k : ℕ), L α (k * p)⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) All goals completed! 🐙 α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L β 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) α:Programβ:Programhαβ:α.testFree ∧ β.testFreeh0:L β 0p:ℕhp:0 < phLp:∀ (k : ℕ), L β (k * p)⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (α⋓β) (k * p) All goals completed! 🐙 α:Programhα:(∗α).testFreex✝:L (∗α) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (∗α) (k * p) α:Programhα:(∗α).testFreex✝:L (∗α) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (∗α) (k * p) α:Programhα:α.testFreex✝:L (∗α) 0⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (∗α) (k * p) α:Programhα:α.testFreex✝:L (∗α) 0p:ℕhp:0 < phLp:L α p⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), L (∗α) (k * p) refine ⟨p, hp, fun k => ⟨List.replicate k p, ?_, α:Programhα:α.testFreex✝:L (∗α) 0p:ℕhp:0 < phLp:L α pk:ℕ⊢ k * p = (List.replicate k p).sum All goals completed! 🐙⟩⟩ α:Programhα:α.testFreex✝:L (∗α) 0p:ℕhp:0 < phLp:L α pk:ℕi:ℕhi:i ∈ List.replicate k p⊢ L α i α:Programhα:α.testFreex✝:L (∗α) 0p:ℕhp:0 < phLp:L α pk:ℕi:ℕhi:i ∈ List.replicate k p⊢ L α p All goals completed! 🐙

The converse, for the sets without these obstructions

aPow n is the program a^(n+1), i.e. a ;' ⋯ ;' a with n + 1 copies of a = ·0.

def aPow : ℕ → Program | 0 => ·0 | n + 1 => ·0 ;' aPow n
@[simp] lemma L_aPow (n m : ℕ) : L (aPow n) m ↔ m = n + 1 := n:ℕm:ℕ⊢ L (aPow n) m ↔ m = n + 1 induction n generalizing m with m:ℕ⊢ L (aPow 0) m ↔ m = 0 + 1 All goals completed! 🐙 n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1m:ℕ⊢ L (aPow (n + 1)) m ↔ m = n + 1 + 1 n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1m:ℕ⊢ (∃ i j, i = 1 ∧ j = n + 1 ∧ m = i + j) ↔ m = n + 1 + 1 n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1m:ℕ⊢ (∃ i j, i = 1 ∧ j = n + 1 ∧ m = i + j) → m = n + 1 + 1n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1m:ℕ⊢ m = n + 1 + 1 → ∃ i j, i = 1 ∧ j = n + 1 ∧ m = i + j n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1m:ℕ⊢ (∃ i j, i = 1 ∧ j = n + 1 ∧ m = i + j) → m = n + 1 + 1 n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1⊢ 1 + (n + 1) = n + 1 + 1; All goals completed! 🐙 n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1m:ℕ⊢ m = n + 1 + 1 → ∃ i j, i = 1 ∧ j = n + 1 ∧ m = i + j n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1⊢ ∃ i j, i = 1 ∧ j = n + 1 ∧ n + 1 + 1 = i + j; exact ⟨1, n + 1, rfl, rfl, n:ℕIH:∀ (m : ℕ), L (aPow n) m ↔ m = n + 1⊢ n + 1 + 1 = 1 + (n + 1) All goals completed! 🐙⟩lemma aPow_testFree (n : ℕ) : (aPow n).testFree := n:ℕ⊢ (aPow n).testFree ⊢ (aPow 0).testFreen✝:ℕa✝:(aPow n✝).testFree⊢ (aPow (n✝ + 1)).testFree ⊢ (aPow 0).testFreen✝:ℕa✝:(aPow n✝).testFree⊢ (aPow (n✝ + 1)).testFree All goals completed! 🐙lemma aPow_voc (n : ℕ) : (aPow n).voc = {Sum.inr 0} := n:ℕ⊢ (aPow n).voc = {Sum.inr 0} ⊢ (aPow 0).voc = {Sum.inr 0}n✝:ℕa✝:(aPow n✝).voc = {Sum.inr 0}⊢ (aPow (n✝ + 1)).voc = {Sum.inr 0} ⊢ (aPow 0).voc = {Sum.inr 0}n✝:ℕa✝:(aPow n✝).voc = {Sum.inr 0}⊢ (aPow (n✝ + 1)).voc = {Sum.inr 0} All goals completed! 🐙

IsL X: the set X ⊆ ℕ is L α for a test-free program α with voc α = {a}.

def IsL (X : Set ℕ) : Prop := ∃ α : Program, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X
lemma IsL.union {X Y : Set ℕ} (hX : IsL X) (hY : IsL Y) : IsL (X ∪ Y) := X:Set ℕY:Set ℕhX:IsL XhY:IsL Y⊢ IsL (X ∪ Y) Y:Set ℕhY:IsL Yα:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}⊢ IsL ({n | L α n} ∪ Y) α:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}β:Programhβ:β.testFreehvβ:β.voc = {Sum.inr 0}⊢ IsL ({n | L α n} ∪ {n | L β n}) exact ⟨α ⋓ β, ⟨hα, hβ⟩, α:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}β:Programhβ:β.testFreehvβ:β.voc = {Sum.inr 0}⊢ (α⋓β).voc = {Sum.inr 0} All goals completed! 🐙, L_union_set α β⟩lemma IsL.add {X Y : Set ℕ} (hX : IsL X) (hY : IsL Y) : IsL (X + Y) := X:Set ℕY:Set ℕhX:IsL XhY:IsL Y⊢ IsL (X + Y) Y:Set ℕhY:IsL Yα:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}⊢ IsL ({n | L α n} + Y) α:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}β:Programhβ:β.testFreehvβ:β.voc = {Sum.inr 0}⊢ IsL ({n | L α n} + {n | L β n}) exact ⟨α ;' β, ⟨hα, hβ⟩, α:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}β:Programhβ:β.testFreehvβ:β.voc = {Sum.inr 0}⊢ (α;'β).voc = {Sum.inr 0} All goals completed! 🐙, L_seq_set α β⟩lemma IsL.closure {X : Set ℕ} (hX : IsL X) : IsL (closure X : Set ℕ) := X:Set ℕhX:IsL X⊢ IsL ↑(AddSubmonoid.closure X) α:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}⊢ IsL ↑(AddSubmonoid.closure {n | L α n}) exact ⟨∗α, hα, α:Programhα:α.testFreehvα:α.voc = {Sum.inr 0}⊢ (∗α).voc = {Sum.inr 0} All goals completed! 🐙, L_star_set α⟩lemma IsL.singleton_succ (n : ℕ) : IsL {n + 1} := ⟨aPow n, aPow_testFree n, aPow_voc n, n:ℕ⊢ {n_1 | L (aPow n) n_1} = {n + 1} n:ℕm:ℕ⊢ m ∈ {n_1 | L (aPow n) n_1} ↔ m ∈ {n + 1}; All goals completed! 🐙⟩lemma IsL.singleton_of_pos {n : ℕ} (hn : 0 < n) : IsL {n} := n:ℕhn:0 < n⊢ IsL {n} m:ℕhn:0 < m + 1⊢ IsL {m + 1} All goals completed! 🐙

The positive part of a proper linear subset of ℕ is empty or IsL.

lemma IsProperLinearSet.isL_diff_zero {s : Set ℕ} (hs : IsProperLinearSet s) : s \ {0} = ∅ ∨ IsL (s \ {0}) := s:Set ℕhs:IsProperLinearSet s⊢ s \ {0} = ∅ ∨ IsL (s \ {0}) s:Set ℕhs:∃ a t, LinearIndepOn ℕ id ↑t ∧ s = a +ᵥ ↑(closure ↑t)⊢ s \ {0} = ∅ ∨ IsL (s \ {0}) a:ℕt:Finset ℕht:LinearIndepOn ℕ id ↑t⊢ (a +ᵥ ↑(closure ↑t)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑t)) \ {0}) a:ℕt:Finset ℕht:LinearIndepOn ℕ id ↑thcard:#t ≤ 1⊢ (a +ᵥ ↑(closure ↑t)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑t)) \ {0}) simp_rw a:ℕt:Finset ℕht:LinearIndepOn ℕ id ↑thcard:#t ≤ 1⊢ (a +ᵥ ↑(closure ↑t)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑t)) \ {0})a:ℕt:Finset ℕht:LinearIndepOn ℕ id ↑thcard:∃ x, t ⊆ {x}⊢ (a +ᵥ ↑(closure ↑t)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑t)) \ {0}) a:ℕt:Finset ℕht:LinearIndepOn ℕ id ↑thcard:∃ x, t = ∅ ∨ t = {x}⊢ (a +ᵥ ↑(closure ↑t)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑t)) \ {0})] at hcard a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅⊢ (a +ᵥ ↑(closure ↑∅)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑∅)) \ {0})a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}⊢ (a +ᵥ ↑(closure ↑{b})) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅⊢ (a +ᵥ ↑(closure ↑∅)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑∅)) \ {0}) -- `s = {a}` a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅hs:a +ᵥ ↑(closure ↑∅) = {a}⊢ (a +ᵥ ↑(closure ↑∅)) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑∅)) \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅hs:a +ᵥ ↑(closure ↑∅) = {a}⊢ {a} \ {0} = ∅ ∨ IsL ({a} \ {0}) b:ℕht:LinearIndepOn ℕ id ↑∅hs:0 +ᵥ ↑(closure ↑∅) = {0}⊢ {0} \ {0} = ∅ ∨ IsL ({0} \ {0})a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅hs:a +ᵥ ↑(closure ↑∅) = {a}ha:a > 0⊢ {a} \ {0} = ∅ ∨ IsL ({a} \ {0}) b:ℕht:LinearIndepOn ℕ id ↑∅hs:0 +ᵥ ↑(closure ↑∅) = {0}⊢ {0} \ {0} = ∅ ∨ IsL ({0} \ {0}) b:ℕht:LinearIndepOn ℕ id ↑∅hs:0 +ᵥ ↑(closure ↑∅) = {0}⊢ {0} \ {0} = ∅; All goals completed! 🐙 a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅hs:a +ᵥ ↑(closure ↑∅) = {a}ha:a > 0⊢ {a} \ {0} = ∅ ∨ IsL ({a} \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅hs:a +ᵥ ↑(closure ↑∅) = {a}ha:a > 0⊢ IsL ({a} \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑∅hs:a +ᵥ ↑(closure ↑∅) = {a}ha:a > 0⊢ IsL {a} All goals completed! 🐙 a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}⊢ (a +ᵥ ↑(closure ↑{b})) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) -- `s = a + bℕ` with `b ≠ 0` a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0⊢ (a +ᵥ ↑(closure ↑{b})) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < b⊢ (a +ᵥ ↑(closure ↑{b})) \ {0} = ∅ ∨ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < b⊢ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = n⊢ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = n⊢ IsL ((0 +ᵥ ↑(closure ↑{b})) \ {0})a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0⊢ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = n⊢ IsL ((0 +ᵥ ↑(closure ↑{b})) \ {0}) -- `bℕ \ {0} = {b} + bℕ` b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = n⊢ (0 +ᵥ ↑(closure ↑{b})) \ {0} = {b} + ↑(closure {b}) b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nn:ℕ⊢ n ∈ (0 +ᵥ ↑(closure ↑{b})) \ {0} ↔ n ∈ {b} + ↑(closure {b}) b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nn:ℕ⊢ (∃ m, m * b = n) ∧ ¬n = 0 ↔ ∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nn:ℕ⊢ (∃ m, m * b = n) ∧ ¬n = 0 → ∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = nb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nn:ℕ⊢ (∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n) → (∃ m, m * b = n) ∧ ¬n = 0 b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nn:ℕ⊢ (∃ m, m * b = n) ∧ ¬n = 0 → ∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nm:ℕhm:¬m * b = 0⊢ ∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = m * b b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nm:ℕhm:¬(m + 1) * b = 0⊢ ∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = (m + 1) * b exact ⟨b, rfl, m * b, ⟨m, rfl⟩, b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nm:ℕhm:¬(m + 1) * b = 0⊢ b + m * b = (m + 1) * b All goals completed! 🐙⟩ b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{b}) ↔ ∃ m, 0 + m * b = nn:ℕ⊢ (∃ x, x = b ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n) → (∃ m, m * b = n) ∧ ¬n = 0 x:ℕht:LinearIndepOn ℕ id ↑{x}hb:x ≠ 0hb':0 < xhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{x}) ↔ ∃ m, 0 + m * x = nm:ℕ⊢ (∃ m_1, m_1 * x = x + m * x) ∧ ¬x + m * x = 0 exact ⟨⟨m + 1, x:ℕht:LinearIndepOn ℕ id ↑{x}hb:x ≠ 0hb':0 < xhmem:∀ (n : ℕ), n ∈ 0 +ᵥ ↑(closure ↑{x}) ↔ ∃ m, 0 + m * x = nm:ℕ⊢ (m + 1) * x = x + m * x All goals completed! 🐙⟩, (Nat.add_pos_left hb' _).ne'⟩ a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0⊢ IsL ((a +ᵥ ↑(closure ↑{b})) \ {0}) -- `(a + bℕ) \ {0} = {a} + bℕ` a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0⊢ (a +ᵥ ↑(closure ↑{b})) \ {0} = {a} + ↑(closure {b}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0n:ℕ⊢ n ∈ (a +ᵥ ↑(closure ↑{b})) \ {0} ↔ n ∈ {a} + ↑(closure {b}) a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0n:ℕ⊢ (∃ m, a + m * b = n) ∧ ¬n = 0 ↔ ∃ x, x = a ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0n:ℕ⊢ (∃ m, a + m * b = n) ∧ ¬n = 0 → ∃ x, x = a ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = na:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0n:ℕ⊢ (∃ x, x = a ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n) → (∃ m, a + m * b = n) ∧ ¬n = 0 a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0n:ℕ⊢ (∃ m, a + m * b = n) ∧ ¬n = 0 → ∃ x, x = a ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0m:ℕ⊢ ∃ x, x = a ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = a + m * b All goals completed! 🐙 a:ℕb:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bhmem:∀ (n : ℕ), n ∈ a +ᵥ ↑(closure ↑{b}) ↔ ∃ m, a + m * b = nha:a > 0n:ℕ⊢ (∃ x, x = a ∧ ∃ y, (∃ n, n * b = y) ∧ x + y = n) → (∃ m, a + m * b = n) ∧ ¬n = 0 b:ℕht:LinearIndepOn ℕ id ↑{b}hb:b ≠ 0hb':0 < bx:ℕhmem:∀ (n : ℕ), n ∈ x +ᵥ ↑(closure ↑{b}) ↔ ∃ m, x + m * b = nha:x > 0m:ℕ⊢ (∃ m_1, x + m_1 * b = x + m * b) ∧ ¬x + m * b = 0 All goals completed! 🐙

The positive part of a semilinear subset of ℕ is empty or IsL.

lemma IsSemilinearSet.isL_diff_zero {X : Set ℕ} (hX : IsSemilinearSet X) : X \ {0} = ∅ ∨ IsL (X \ {0}) := X:Set ℕhX:IsSemilinearSet X⊢ X \ {0} = ∅ ∨ IsL (X \ {0}) S:Finset (Set ℕ)hS:∀ t ∈ S, IsProperLinearSet thX:IsSemilinearSet (⋃₀ ↑S)⊢ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0}) S:Finset (Set ℕ)hS:∀ t ∈ S, IsProperLinearSet t⊢ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0}) induction S using Finset.induction_on with hS:∀ t ∈ ∅, IsProperLinearSet t⊢ ⋃₀ ↑∅ \ {0} = ∅ ∨ IsL (⋃₀ ↑∅ \ {0}) hS:∀ t ∈ ∅, IsProperLinearSet t⊢ ⋃₀ ↑∅ \ {0} = ∅; All goals completed! 🐙 t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:∀ t_1 ∈ insert t S, IsProperLinearSet t_1⊢ ⋃₀ ↑(insert t S) \ {0} = ∅ ∨ IsL (⋃₀ ↑(insert t S) \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet a⊢ ⋃₀ ↑(insert t S) \ {0} = ∅ ∨ IsL (⋃₀ ↑(insert t S) \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet a⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:t \ {0} = ∅⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0})t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:t \ {0} = ∅⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0})t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})h2:⋃₀ ↑S \ {0} = ∅⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0})t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})h2:IsL (⋃₀ ↑S \ {0})⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:t \ {0} = ∅h2:⋃₀ ↑S \ {0} = ∅⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:t \ {0} = ∅h2:⋃₀ ↑S \ {0} = ∅⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅; All goals completed! 🐙 t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:t \ {0} = ∅h2:IsL (⋃₀ ↑S \ {0})⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:t \ {0} = ∅h2:IsL (⋃₀ ↑S \ {0})⊢ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}); All goals completed! 🐙 t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})h2:⋃₀ ↑S \ {0} = ∅⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})h2:⋃₀ ↑S \ {0} = ∅⊢ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}); All goals completed! 🐙 t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})h2:IsL (⋃₀ ↑S \ {0})⊢ t \ {0} ∪ ⋃₀ ↑S \ {0} = ∅ ∨ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}) t:Set ℕS:Finset (Set ℕ)a✝:t ∉ SIH:(∀ t ∈ S, IsProperLinearSet t) → ⋃₀ ↑S \ {0} = ∅ ∨ IsL (⋃₀ ↑S \ {0})hS:IsProperLinearSet t ∧ ∀ a ∈ S, IsProperLinearSet ah1:IsL (t \ {0})h2:IsL (⋃₀ ↑S \ {0})⊢ IsL (t \ {0} ∪ ⋃₀ ↑S \ {0}); All goals completed! 🐙

The sets L α for test-free α with voc α = {a} are exactly the nonempty semilinear sets X ⊆ ℕ such that, if 0 ∈ X, then X contains all multiples of some p > 0.

theorem exists_L_eq_iff (X : Set ℕ) : (∃ α : Program, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X) ↔ IsSemilinearSet X ∧ X.Nonempty ∧ (0 ∈ X → ∃ p, 0 < p ∧ ∀ k, k * p ∈ X) := X:Set ℕ⊢ (∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X) ↔ IsSemilinearSet X ∧ X.Nonempty ∧ (0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ X) X:Set ℕ⊢ (∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X) → IsSemilinearSet X ∧ X.Nonempty ∧ (0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ X)X:Set ℕ⊢ IsSemilinearSet X ∧ X.Nonempty ∧ (0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ X) → ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕ⊢ (∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X) → IsSemilinearSet X ∧ X.Nonempty ∧ (0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ X) α:Programhα:α.testFree⊢ IsSemilinearSet {n | L α n} ∧ {n | L α n}.Nonempty ∧ (0 ∈ {n | L α n} → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ {n | L α n}) α:Programhα:α.testFree⊢ {n | L α n}.Nonemptyα:Programhα:α.testFree⊢ 0 ∈ {n | L α n} → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ {n | L α n} α:Programhα:α.testFree⊢ {n | L α n}.Nonempty α:Programhα:α.testFreen:ℕhn:L α n⊢ {n | L α n}.Nonempty All goals completed! 🐙 α:Programhα:α.testFree⊢ 0 ∈ {n | L α n} → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ {n | L α n} α:Programhα:α.testFreeh0:0 ∈ {n | L α n}⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ {n | L α n} α:Programhα:α.testFreeh0:0 ∈ {n | L α n}p:ℕhp:0 < phLp:∀ (k : ℕ), L α (k * p)⊢ ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ {n | L α n} All goals completed! 🐙 X:Set ℕ⊢ IsSemilinearSet X ∧ X.Nonempty ∧ (0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ X) → ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ X⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X \ {0} = ∅⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = XX:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X \ {0} = ∅⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X -- then `X ⊆ {0}`, so `X = {0}`, which is excluded X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X \ {0} = ∅⊢ False X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X ⊆ {0}⊢ False X:Set ℕhX:IsSemilinearSet Xh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X ⊆ {0}x:ℕhx:x ∈ X⊢ False X:Set ℕhX:IsSemilinearSet Xh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X ⊆ {0}hx:0 ∈ X⊢ False X:Set ℕhX:IsSemilinearSet Xh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X ⊆ {0}hx:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ X⊢ False X:Set ℕhX:IsSemilinearSet Xh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X ⊆ {0}hx:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xthis:1 * p ∈ {0}⊢ False X:Set ℕhX:IsSemilinearSet Xh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:X ⊆ {0}hx:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xthis:p = 0⊢ False All goals completed! 🐙 X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ X⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = XX:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∉ X⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ X⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ X⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})⊢ {n | L α n} = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})⊢ X \ {0} ∪ ↑(closure {p}) = X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕ⊢ n ∈ X \ {0} ∪ ↑(closure {p}) ↔ n ∈ X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕ⊢ (n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n) ↔ n ∈ X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕ⊢ (n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n) → n ∈ XX:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕ⊢ n ∈ X → n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕ⊢ (n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n) → n ∈ X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ X⊢ n ∈ XX:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})k:ℕ⊢ k * p ∈ X X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ X⊢ n ∈ X All goals completed! 🐙 X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})k:ℕ⊢ k * p ∈ X All goals completed! 🐙 X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕ⊢ n ∈ X → n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ X⊢ n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ Xhn0:n = 0⊢ n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = nX:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ Xhn0:¬n = 0⊢ n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ Xhn0:n = 0⊢ n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n exact Or.inr ⟨0, X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ Xhn0:n = 0⊢ 0 * p = n All goals completed! 🐙⟩ X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∈ Xp:ℕhp:0 < phLp:∀ (k : ℕ), k * p ∈ Xα:Programhα:α.testFreehv:α.voc = {Sum.inr 0}hL:{n | L α n} = X \ {0} ∪ ↑(closure {p})n:ℕhn:n ∈ Xhn0:¬n = 0⊢ n ∈ X ∧ ¬n = 0 ∨ ∃ n_1, n_1 * p = n All goals completed! 🐙 X:Set ℕhX:IsSemilinearSet Xhne:X.Nonemptyh0:0 ∈ X → ∃ p, 0 < p ∧ ∀ (k : ℕ), k * p ∈ Xh:IsL (X \ {0})h0X:0 ∉ X⊢ ∃ α, α.testFree ∧ α.voc = {Sum.inr 0} ∧ {n | L α n} = X All goals completed! 🐙