Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion.
•
79 items
•
Updated
•
2
fact
stringlengths 9
121k
| type
stringclasses 10
values | library
stringclasses 2
values | imports
listlengths 0
18
| filename
stringclasses 194
values | symbolic_name
stringlengths 1
49
| docstring
stringclasses 225
values |
|---|---|---|---|---|---|---|
e : ℕ ≃ ℕ ⊕ α := Classical.choice (inferInstance : Nonempty (ℕ ≃ ℕ ⊕ α))
|
def
|
equational_theories
|
[
"import Mathlib.Data.Countable.Defs",
"import Mathlib.Data.Sum.Basic",
"import Mathlib.SetTheory.Cardinal.Arithmetic"
] |
equational_theories/AdjoinFresh.lean
|
e
| null |
adjoinFresh (m : ℕ) : ℕ ≃ ℕ ⊕ α where toFun n := if n < m then .inl n else match e (n - m) with | .inl k => .inl (k + m) | .inr c => .inr c invFun | .inl k => if k < m then k else e.symm (.inl (k-m)) + m | .inr c => e.symm (.inr c) + m left_inv n := by dsimp by_cases h : n < m · simp [h] · simp [h] cases h' : (e (α:=α) (n -m)) · simp only [add_lt_iff_neg_right, not_lt_zero', ↓reduceIte, add_tsub_cancel_right] rw [← h'] simp only [Equiv.symm_apply_apply] aesop · simp [← h'] omega right_inv a := by cases a case inl n => simp only by_cases h : n < m · simp [h] · simp only [h, ↓reduceIte, Nat.add_sub_cancel, Equiv.apply_symm_apply] have : ¬ ((e (α := α)).symm (Sum.inl (n - m)) + m < m) := by omega simp only [this, ↓reduceIte, Sum.inl.injEq] omega case inr => simp
|
def
|
equational_theories
|
[
"import Mathlib.Data.Countable.Defs",
"import Mathlib.Data.Sum.Basic",
"import Mathlib.SetTheory.Cardinal.Arithmetic"
] |
equational_theories/AdjoinFresh.lean
|
adjoinFresh
| null |
adjoinFresh_fixed {m k: ℕ} (h : k < m) : adjoinFresh (α := α) m k = .inl k := by unfold adjoinFresh; simp [h]
|
theorem
|
equational_theories
|
[
"import Mathlib.Data.Countable.Defs",
"import Mathlib.Data.Sum.Basic",
"import Mathlib.SetTheory.Cardinal.Arithmetic"
] |
equational_theories/AdjoinFresh.lean
|
adjoinFresh_fixed
| null |
adjoinFresh_fixed' {m k: ℕ} (h : k < m) : (adjoinFresh (α := α ) m).symm (.inl k) = k := by unfold adjoinFresh; simp [h]
|
theorem
|
equational_theories
|
[
"import Mathlib.Data.Countable.Defs",
"import Mathlib.Data.Sum.Basic",
"import Mathlib.SetTheory.Cardinal.Arithmetic"
] |
equational_theories/AdjoinFresh.lean
|
adjoinFresh_fixed'
| null |
PartialSolution where E0 : Finset (G × G) E1 : Finset (G × G) f : G → G → G E0_subset_E1 : E0 ⊆ E1 t_mem_of_mem_E0' : ∀ x ∈ E0, (x.2, f x.1 x.2) ∈ E1 mem_2_of_mem_E0 : ∀ x ∈ E0, (x.1, f x.2 (f x.1 x.2)) ∈ E1 eq_of_mem_E0 : ∀ x ∈ E0, f x.1 (f x.2 (f x.1 x.2)) = x.2 undef_of_not_mem_E0' : ∀ x ∈ E1 \ E0, (x.2, f x.1 x.2) ∉ E1 strange: ∀ x ∈ E1, f x.1 x.2 = x.1 → ((x.2, x.2) ∈ E1 ∧ f x.2 x.2 = x.1)
|
structure
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution
| null |
PartialSolution.g (f : PartialSolution G) : G × G → G × G := fun (x, y) => (y, f.f x y)
|
abbrev
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.g
| null |
PartialSolution.le_def {a b : PartialSolution G} : a ≤ b ↔ a.E0 ≤ b.E0 ∧ a.E1 ≤ b.E1 ∧ Set.EqOn a.f.uncurry b.f.uncurry a.E1 := Iff.rfl
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_def
| null |
PartialSolution.t_mem_of_mem_E0 (f : PartialSolution G) {x : G × G} (hx : x ∈ f.E0) : f.g x ∈ f.E1 := f.t_mem_of_mem_E0' x hx
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.t_mem_of_mem_E0
| null |
PartialSolution.undef_of_not_mem_E0 (f : PartialSolution G) (x : G × G) (hx : x ∉ f.E0) (hx2 : x ∈ f.E1) : f.g x ∉ f.E1 := f.undef_of_not_mem_E0' x (by simp [*])
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.undef_of_not_mem_E0
| null |
PartialSolution.move_rev_good (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) : PartialSolution G := let f' y' x' := if y' = y ∧ x' = x then z else if x' = z then y else f.f y' x' have f'_of_mem_E1 {a b : G} (ha : (a, b) ∈ f.E1) : f' a b = f.f a b := by dsimp [f'] rw [if_neg, if_neg] · exact hz1 _ ha · rintro ⟨rfl, rfl⟩; exact h1 ha have f'_of_mem_E0 {a b : G} (ha : (a, b) ∈ f.E0) : f' a b = f.f a b := f'_of_mem_E1 (f.E0_subset_E1 ha) have f'_y_x : f' y x = z := by simp [f'] have f'_z {a : G} : f' a z = y := by simp [f', hzx] { E0 := f.E0 ∪ (f.E1.filter fun ⟨y', x'⟩ ↦ x' = y ∧ f.f y' x' = x) E1 := f.E1 ∪ {(y, x), (z, z)} ∪ (f.E1.filter fun ⟨y', x'⟩ ↦ x' = y ∧ f.f y' x' = x).image fun ⟨y', _⟩ ↦ (y', z) f := f' E0_subset_E1 := by trans f.E1 · exact Finset.union_subset (f.E0_subset_E1) (Finset.filter_subset ..) · rw [Finset.union_assoc]; exact Finset.subset_union_left t_mem_of_mem_E0' := by rintro ⟨x', y'⟩ ha simp only [Finset.mem_union, Finset.mem_filter] at ha rcases ha with ha | ⟨ha, rfl, rfl⟩ · rw [f'_of_mem_E0 ha]; simp [f.t_mem_of_mem_E0 ha] · rw [f'_of_mem_E1 ha]; simp mem_2_of_mem_E0 := by rintro ⟨x', y'⟩ ha simp only [Finset.mem_union, Finset.mem_filter] at ha rcases ha with ha | ⟨ha, rfl, rfl⟩ · rw [f'_of_mem_E0 ha, f'_of_mem_E1 (f.t_mem_of_mem_E0 ha)] simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, f.mem_2_of_mem_E0 _ ha, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right, true_or, or_true] · rw [f'_of_mem_E1 ha, f'_y_x] apply Finset.mem_union_right simp only [Finset.mem_image, Finset.mem_filter, Prod.mk.injEq, and_true, Prod.exists, exists_and_right, exists_eq_right] use y' eq_of_mem_E0 := by rintro ⟨x', y'⟩ ha simp only [Finset.mem_union, Finset.mem_filter] at ha rcases ha with ha | ⟨ha, rfl, rfl⟩ · rw [f'_of_mem_E0 ha, f'_of_mem_E1 (f.t_mem_of_mem_E0 ha), f'_of_mem_E1 (f.mem_2_of_mem_E0 _ ha)] apply f.eq_of_mem_E0 _ ha · rw [f'_of_mem_E1 ha, f'_y_x, f'_z] undef_of_not_mem_E0' := by rintro ⟨x', y'⟩ ha simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_sdiff, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right, not_or, not_and] at ha obtain ⟨⟨rfl, rfl⟩ | ha | ⟨rfl, rfl⟩ | ⟨a, ⟨⟨x, ha, rfl, rfl⟩, rfl, rfl⟩⟩, ha2, ha3⟩ := ha · rw [f'_y_x] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, and_true, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right, exists_eq_right] at mem obtain ⟨rfl, rfl⟩ | mem | rfl | ⟨x, mem, rfl, mem2⟩ := mem · exact hzx rfl · exact hz1 _ mem rfl · exact hzx rfl · exact h2 mem mem2 · rw [f'_of_mem_E1 ha] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at mem obtain ⟨rfl, rfl⟩ | mem | ⟨rfl, mem⟩ | ⟨x, -, rfl, mem2⟩ := mem · exact ha3 ha rfl rfl · exact f.undef_of_not_mem_E0 _ ha2 ha mem · exact hz1 _ ha rfl · exact hz2 _ ha mem2.symm · rw [f'_z] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, true_and, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at mem obtain ⟨rfl, rfl⟩ | mem | ⟨rfl, mem⟩ | ⟨x, mem, rfl, rfl⟩ := mem · exact hzx rfl · exact hz3 _ mem rfl · exact hzy rfl · exact hzy rfl · rw [f'_z] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, true_and, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at mem obtain ⟨rfl, mem⟩ | mem | ⟨rfl, mem⟩ | ⟨x, mem, rfl, rfl⟩ := mem · exact hzy rfl · exact hz3 _ mem rfl · exact hzy rfl · exact hzy rfl strange := by rintro ⟨x', y'⟩ ha heq simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at ha dsimp only at heq ⊢ obtain ⟨rfl, rfl⟩ | ha | ⟨rfl, rfl⟩ | ⟨a, ⟨⟨x, -, rfl, rfl⟩, rfl, rfl⟩⟩ := ha · exact (hzy (f'_y_x ▸ heq)).elim · rw [f'_of_mem_E1 ha] at heq simp [f.strange _ ha heq, f'_of_mem_E1] · simp [heq] · simp only [Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, true_or, or_true, f'_z, true_and] rw [← heq, f'_z] }
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.move_rev_good
| null |
PartialSolution.le_move_rev_good (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) : f ≤ f.move_rev_good x y z h1 h2 hz1 hz2 hz3 hzx hzy := by simp only [move_rev_good, Finset.union_assoc, le_def, Finset.le_eq_subset, Finset.subset_union_left, true_and] rintro ⟨x', y'⟩ mem simp only [Function.uncurry_apply_pair] rw [if_neg, if_neg] · exact hz1 _ mem · rintro ⟨rfl, rfl⟩ exact h1 mem
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_move_rev_good
| null |
PartialSolution.mem_move_rev_good (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) : (y, x) ∈ (f.move_rev_good x y z h1 h2 hz1 hz2 hz3 hzx hzy).E1 := by simp [move_rev_good]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_good
| null |
PartialSolution.mem_move_rev_good_of_app_eq (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) (a : G) (hbm : (a, y) ∈ f.E1) (hp : f.f a y = x) : (a, y) ∈ (f.move_rev_good x y z h1 h2 hz1 hz2 hz3 hzx hzy).E0 := by simp [move_rev_good, hbm, hp]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_good_of_app_eq
| null |
PartialSolution.move_rev_bad (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) : PartialSolution G := let f' y' x' := if y' = y ∧ x' = x then z else if x' = z then y else f.f y' x' have f'_of_mem_E1 {a b : G} (ha : (a, b) ∈ f.E1) : f' a b = f.f a b := by dsimp [f'] rw [if_neg, if_neg] · exact hz1 _ ha · rintro ⟨rfl, rfl⟩ exact h1 ha have f'_of_mem_E0 {a b : G} (ha : (a, b) ∈ f.E0) : f' a b = f.f a b := f'_of_mem_E1 (f.E0_subset_E1 ha) have f'_y_x : f' y x = z := by simp [f'] have f'_z {a : G} : f' a z = y := by simp [f', hzx] { E0 := f.E0 ∪ {(y, x)} ∪ (f.E1.filter fun ⟨y', x'⟩ ↦ x' = y ∧ f.f y' x' = x) E1 := f.E1 ∪ {(y, x), (z, z)} ∪ (f.E1.filter fun ⟨y', x'⟩ ↦ x' = y ∧ f.f y' x' = x).image fun ⟨y', _⟩ ↦ (y', z) f := f' E0_subset_E1 := by nth_rw 2 [Finset.union_assoc] apply Finset.union_subset apply Finset.union_subset · trans f.E1 exact f.E0_subset_E1 exact Finset.subset_union_left · trans {(y, x), (z, z)} simp only [Finset.singleton_subset_iff, Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq, true_or] exact fun x hx ↦ Finset.mem_union_right _ (Finset.mem_union_left _ hx) · trans f.E1 apply Finset.filter_subset exact Finset.subset_union_left t_mem_of_mem_E0' := by rintro ⟨x', y'⟩ ha simp only [Finset.union_assoc, Finset.mem_union, Finset.mem_singleton, Prod.mk.injEq, Finset.mem_filter] at ha rcases ha with ha | ⟨rfl, rfl⟩ | ⟨ha, rfl, rfl⟩ · rw [f'_of_mem_E0 ha]; simp [f.t_mem_of_mem_E0 ha] · simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] right; right; right use y' simp only [f'_y_x, and_self, and_true] use x' · rw [f'_of_mem_E1 ha]; simp mem_2_of_mem_E0 := by rintro ⟨x', y'⟩ ha simp only [Finset.union_assoc, Finset.mem_union, Finset.mem_singleton, Prod.mk.injEq, Finset.mem_filter] at ha rcases ha with ha | ⟨rfl, rfl⟩ | ⟨ha, rfl, rfl⟩ · rw [f'_of_mem_E0 ha, f'_of_mem_E1 (f.t_mem_of_mem_E0 ha)] simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, f.mem_2_of_mem_E0 _ ha, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right, true_or, or_true] · simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, f'_y_x, f'_z, Finset.mem_insert, Prod.mk.injEq, true_and, Finset.mem_union, f.strange _ h2 h22, Finset.mem_singleton, and_self, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right, true_or, or_true] · rw [f'_of_mem_E1 ha, f'_y_x] apply Finset.mem_union_right simp only [Finset.mem_image, Finset.mem_filter, Prod.mk.injEq, and_true, Prod.exists, exists_and_right, exists_eq_right] use y' eq_of_mem_E0 := by rintro ⟨x', y'⟩ ha simp only [Finset.union_assoc, Finset.mem_union, Finset.mem_singleton, Prod.mk.injEq, Finset.mem_filter] at ha rcases ha with ha | ⟨rfl, rfl⟩ | ⟨ha, rfl, rfl⟩ · rw [f'_of_mem_E0 ha, f'_of_mem_E1 (f.t_mem_of_mem_E0 ha), f'_of_mem_E1 (f.mem_2_of_mem_E0 _ ha)] apply f.eq_of_mem_E0 _ ha · simp only [f'_y_x, f'_z, f.strange _ h2 h22, f'_of_mem_E1] · rw [f'_of_mem_E1 ha, f'_y_x, f'_z] undef_of_not_mem_E0' := by rintro ⟨x', y'⟩ ha simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_sdiff, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right, not_or, not_and] at ha obtain ⟨⟨rfl, rfl⟩ | ha | ⟨rfl, rfl⟩ | ⟨a, ⟨⟨x, ha, rfl, rfl⟩, rfl, rfl⟩⟩, ha2, ha3, ha4⟩ := ha · simp at ha3 · rw [f'_of_mem_E1 ha] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at mem obtain ⟨rfl, rfl⟩ | mem | ⟨rfl, mem⟩ | ⟨x, -, rfl, mem2⟩ := mem · exact ha4 ha rfl rfl · exact f.undef_of_not_mem_E0 _ ha2 ha mem · exact hz1 _ ha rfl · exact hz2 _ ha mem2.symm · rw [f'_z] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, true_and, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at mem obtain ⟨rfl, rfl⟩ | mem | ⟨rfl, mem⟩ | ⟨x, mem, rfl, rfl⟩ := mem · exact hzx rfl · exact hz3 _ mem rfl · exact hzy rfl · exact hzy rfl · rw [f'_z] intro mem simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, true_and, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at mem obtain ⟨rfl, mem⟩ | mem | ⟨rfl, mem⟩ | ⟨x, mem, rfl, rfl⟩ := mem · exact hzy rfl · exact hz3 _ mem rfl · exact hzy rfl · exact hzy rfl strange := by rintro ⟨x', y'⟩ ha heq simp only [Finset.union_insert, Finset.insert_union, Finset.union_assoc, Finset.mem_insert, Prod.mk.injEq, Finset.mem_union, Finset.mem_singleton, Finset.mem_image, Finset.mem_filter, Prod.exists, exists_and_right] at ha dsimp only at heq ⊢ obtain ⟨rfl, rfl⟩ | ha | ⟨rfl, rfl⟩ | ⟨a, ⟨⟨x, -, rfl, rfl⟩, rfl, rfl⟩⟩ := ha · exact (hzy (f'_y_x ▸ heq)).elim · rw [f'_of_mem_E1 ha] at heq simp [f.strange _ ha heq, f'_of_mem_E1] · simp [heq] · simp only [Finset.mem_insert, Finset.mem_union, Finset.mem_singleton, true_or, or_true, f'_z, true_and] rw [← heq, f'_z] }
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.move_rev_bad
| null |
PartialSolution.le_move_rev_bad (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) : f ≤ f.move_rev_bad x y z h1 h2 h22 hz1 hz2 hz3 hzx hzy := by simp only [move_rev_bad, Finset.union_assoc, le_def, Finset.le_eq_subset, Finset.subset_union_left, true_and] rintro ⟨x', y'⟩ mem simp only [Function.uncurry_apply_pair] rw [if_neg, if_neg] · exact hz1 _ mem · rintro ⟨rfl, rfl⟩ exact h1 mem
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_move_rev_bad
| null |
PartialSolution.mem_move_rev_bad (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) : (y, x) ∈ (f.move_rev_bad x y z h1 h2 h22 hz1 hz2 hz3 hzx hzy).E1 := by simp [move_rev_bad]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_bad
| null |
PartialSolution.mem_move_rev_bad_of_app_eq (f : PartialSolution G) (x y : G) (z : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) (hz1 : ∀ x ∈ f.E1, x.2 ≠ z) (hz2 : ∀ x ∈ f.E1, f.f x.1 x.2 ≠ z) (hz3 : ∀ x ∈ f.E1, x.1 ≠ z) (hzx : z ≠ x) (hzy : z ≠ y) (a : G) (hbm : (a, y) ∈ f.E1) (hp : f.f a y = x) : (a, y) ∈ (f.move_rev_bad x y z h1 h2 h22 hz1 hz2 hz3 hzx hzy).E0 := by simp [move_rev_bad, hbm, hp] variable [Denumerable G]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_bad_of_app_eq
| null |
Denumerable.notMemFinset (s : Finset G) : G := Denumerable.ofNat G (Nat.find (Infinite.exists_notMem_finset (s.image Encodable.encode))) omit [DecidableEq G] in
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
Denumerable.notMemFinset
| null |
Denumerable.notMemFinset_prop (s : Finset G) : Denumerable.notMemFinset s ∉ s := by simp only [notMemFinset, Finset.mem_image, not_exists, not_and, Denumerable.decode_eq_ofNat, Option.some.injEq] intro mem have : Nat.find (Infinite.exists_notMem_finset (s.image Encodable.encode)) ∈ s.image Encodable.encode := by rw [Finset.mem_image] exact ⟨_, mem, by simp⟩ have : Nat.find (Infinite.exists_notMem_finset (s.image Encodable.encode)) ∉ s.image Encodable.encode := Nat.find_spec (Infinite.exists_notMem_finset (s.image Encodable.encode)) contradiction
|
theorem
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
Denumerable.notMemFinset_prop
| null |
PartialSolution.move_rev_good' (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) : PartialSolution G := by -- This intentionally used `by` for data. let z : G := Denumerable.notMemFinset (f.E1.image (·.1) ∪ f.E1.image (·.2) ∪ f.E1.image (fun ⟨a, b⟩ ↦ f.f a b) ∪ {x, y}) have zp := Denumerable.notMemFinset_prop (f.E1.image (·.1) ∪ f.E1.image (·.2) ∪ f.E1.image (fun ⟨a, b⟩ ↦ f.f a b) ∪ {x, y}) change z ∉ _ at zp simp only [Finset.union_assoc, Finset.union_insert, Finset.mem_insert, Finset.mem_union, Finset.mem_image, Prod.exists, exists_and_right, exists_eq_right, Finset.mem_singleton, not_or, not_exists, not_and] at zp exact f.move_rev_good x y z h1 h2 (fun x hx nh ↦ zp.2.2.1 x.1 (by convert hx; simp [nh])) (fun x hx ↦ zp.2.2.2.1 x.1 x.2 hx) (fun x hx nh ↦ zp.2.1 x.2 (by convert hx; simp [nh])) zp.1 zp.2.2.2.2
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.move_rev_good'
| null |
PartialSolution.le_move_rev_good' (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) : f ≤ f.move_rev_good' x y h1 h2 := by simp [move_rev_good', le_move_rev_good]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_move_rev_good'
| null |
PartialSolution.mem_move_rev_good' (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) : (y, x) ∈ (f.move_rev_good' x y h1 h2).E1 := by simp [move_rev_good', mem_move_rev_good]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_good'
| null |
PartialSolution.mem_move_rev_good'_of_app_eq (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1 → f.f x y ≠ x) (a : G) (hbm : (a, y) ∈ f.E1) (hp : f.f a y = x) : (a, y) ∈ (f.move_rev_good' x y h1 h2).E0 := by simp [move_rev_good', mem_move_rev_good_of_app_eq, hbm, hp]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_good'_of_app_eq
| null |
PartialSolution.move_rev_bad' (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) : PartialSolution G := by let z : G := Denumerable.notMemFinset (f.E1.image (·.1) ∪ f.E1.image (·.2) ∪ f.E1.image (fun ⟨a, b⟩ ↦ f.f a b) ∪ {x, y}) have zp := Denumerable.notMemFinset_prop (f.E1.image (·.1) ∪ f.E1.image (·.2) ∪ f.E1.image (fun ⟨a, b⟩ ↦ f.f a b) ∪ {x, y}) change z ∉ _ at zp simp only [Finset.union_assoc, Finset.union_insert, Finset.mem_insert, Finset.mem_union, Finset.mem_image, Prod.exists, exists_and_right, exists_eq_right, Finset.mem_singleton, not_or, not_exists, not_and] at zp exact f.move_rev_bad x y z h1 h2 h22 (fun x hx nh ↦ zp.2.2.1 x.1 (by convert hx; simp [nh])) (fun x hx ↦ zp.2.2.2.1 x.1 x.2 hx) (fun x hx nh ↦ zp.2.1 x.2 (by convert hx; simp [nh])) zp.1 zp.2.2.2.2
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.move_rev_bad'
| null |
PartialSolution.le_move_rev_bad' (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) : f ≤ f.move_rev_bad' x y h1 h2 h22 := by simp [move_rev_bad', le_move_rev_bad]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_move_rev_bad'
| null |
PartialSolution.mem_move_rev_bad' (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) : (y, x) ∈ (f.move_rev_bad' x y h1 h2 h22).E1 := by simp [move_rev_bad', mem_move_rev_bad]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_bad'
| null |
PartialSolution.mem_move_rev_bad'_of_app_eq (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (h2 : (x, y) ∈ f.E1) (h22 : f.f x y = x) (a : G) (hbm : (a, y) ∈ f.E1) (hp : f.f a y = x) : (a, y) ∈ (f.move_rev_bad' x y h1 h2 h22).E0 := by simp [move_rev_bad', mem_move_rev_bad_of_app_eq, hbm, hp]
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_move_rev_bad'_of_app_eq
| null |
PartialSolution.act (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) : PartialSolution G := if h2 : (x, y) ∈ f.E1 → f.f x y ≠ x then f.move_rev_good' x y h1 h2 else f.move_rev_bad' x y h1 (by simp_all) (by simp_all)
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.act
| null |
PartialSolution.le_act (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) : f ≤ f.act x y h1 := by unfold act split · apply le_move_rev_good' · apply le_move_rev_bad'
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_act
| null |
PartialSolution.mem_act (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) : (y, x) ∈ (f.act x y h1).E1 := by unfold act split · apply mem_move_rev_good' · apply mem_move_rev_bad'
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_act
| null |
PartialSolution.mem_act_of_app_eq (f : PartialSolution G) (x y : G) (h1 : (y, x) ∉ f.E1) (a : G) (hbm : (a, y) ∈ f.E1) (hp : f.f a y = x) : (a, y) ∈ (f.act x y h1).E0 := by unfold act split · apply mem_move_rev_good'_of_app_eq <;> assumption · apply mem_move_rev_bad'_of_app_eq <;> assumption -- add (y, x)
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_act_of_app_eq
| null |
PartialSolution.add_e1 (f : PartialSolution G) (x y : G) : PartialSolution G := if h1 : (y, x) ∈ f.E1 then f else f.act x y h1
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.add_e1
| null |
PartialSolution.le_add_e1 (f : PartialSolution G) (x y : G) : f ≤ f.add_e1 x y := by unfold add_e1 split · rfl · apply le_act
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_add_e1
| null |
PartialSolution.mem_add_e1 (f : PartialSolution G) (x y : G) : (y, x) ∈ (f.add_e1 x y).E1 := by unfold add_e1 split · assumption · apply mem_act
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_add_e1
| null |
PartialSolution.mem_add_e1_of_app_eq (f : PartialSolution G) (x y : G) (a : G) (hbm : (a, y) ∈ f.E1) (hp : f.f a y = x) : (a, y) ∈ (f.add_e1 x y).E0 := by unfold add_e1 split · by_contra! nh apply f.undef_of_not_mem_E0 _ nh hbm simpa [g, hp] · apply mem_act_of_app_eq <;> assumption
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_add_e1_of_app_eq
| null |
PartialSolution.add_e0 (f : PartialSolution G) (x y : G) : PartialSolution G := let f' := f.add_e1 x y f'.add_e1 (f'.f y x) x
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.add_e0
| null |
PartialSolution.le_add_e0 (f : PartialSolution G) (x y : G) : f ≤ f.add_e0 x y := by unfold add_e0 trans f.add_e1 x y <;> apply le_add_e1
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.le_add_e0
| null |
PartialSolution.mem_add_e0 (f : PartialSolution G) (x y : G) : (y, x) ∈ (f.add_e0 x y).E0 := by apply mem_add_e1_of_app_eq · apply mem_add_e1 · rfl
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
PartialSolution.mem_add_e0
| null |
closureSeq (f : PartialSolution G) : ℕ → PartialSolution G | 0 => f | n+1 => (closureSeq f n).add_e0 (Denumerable.ofNat (G × G) n).2 (Denumerable.ofNat (G × G) n).1
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
closureSeq
| null |
closureSeq_le_closureSeq_succ (f : PartialSolution G) (n : ℕ) : closureSeq f n ≤ closureSeq f (n + 1) := PartialSolution.le_add_e0 ..
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
closureSeq_le_closureSeq_succ
| null |
mem_closureSeq_e0 (f : PartialSolution G) (a b : G) : (a, b) ∈ (closureSeq f (Encodable.encode (a, b) + 1)).E0 := by simp only [closureSeq, ge_iff_le, Equiv.symm_apply_apply, Denumerable.ofNat_encode] apply PartialSolution.mem_add_e0
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
mem_closureSeq_e0
| null |
closureSeq_mono (f : PartialSolution G) : Monotone (closureSeq f) := by intro n m hnm obtain ⟨m, rfl⟩ := Nat.exists_eq_add_of_le hnm clear hnm induction m with | zero => rfl | succ m hm => exact hm.trans (closureSeq_le_closureSeq_succ ..)
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
closureSeq_mono
| null |
le_closureSeq (f : PartialSolution G) (n : ℕ) : f ≤ closureSeq f n := closureSeq_mono f (Nat.zero_le n)
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
le_closureSeq
| null |
closure (f : PartialSolution G) : G → G → G := fun a b ↦ (closureSeq f (Encodable.encode (a, b) + 1)).f a b
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
closure
| null |
closure_eq_of_mem_e1 (f : PartialSolution G) (n : ℕ) (a b : G) (hn : (a, b) ∈ (closureSeq f n).E1) : closure f a b = (closureSeq f n).f a b := by simp only [closure, Prod.mk.eta] rcases le_total n (Encodable.encode (a, b) + 1) with h | h · exact (closureSeq_mono f h).2.2.symm hn · exact (closureSeq_mono f h).2.2 (PartialSolution.E0_subset_E1 _ (mem_closureSeq_e0 f a b))
|
lemma
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
closure_eq_of_mem_e1
| null |
closure_prop (f : PartialSolution G) : ∀ x y, closure f x (closure f y (closure f x y)) = y := by intro x y rw [closure_eq_of_mem_e1 f (Encodable.encode (x, y) + 1) x y, closure_eq_of_mem_e1 f (Encodable.encode (x, y) + 1) y, closure_eq_of_mem_e1 f (Encodable.encode (x, y) + 1)] · exact PartialSolution.eq_of_mem_E0 _ _ (mem_closureSeq_e0 ..) · exact PartialSolution.mem_2_of_mem_E0 _ _ (mem_closureSeq_e0 ..) · exact PartialSolution.t_mem_of_mem_E0' _ _ (mem_closureSeq_e0 ..) · exact PartialSolution.E0_subset_E1 _ (mem_closureSeq_e0 ..)
|
theorem
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
closure_prop
| null |
initial : PartialSolution ℕ where E0 := {(0, 0), (1, 0), (0, 1), (0, 8), (8, 8), (8, 0)} E1 := {(0, 0), (1, 0), (0, 2), (1, 3), (0, 3), (1, 1), (0, 5), (1, 6), (0, 1), (0, 8), (8, 8), (1, 8), (0, 9), (8, 0), (0, 10), (8, 10), (10, 10), (2, 0)} f a b := if a = 0 then [1, 8, 3, 4, 100, 6, 100, 100, 0, 1, 8].getD b 0 else if a = 1 then [2, 5, 100, 0, 100, 100, 7, 100, 9].getD b 0 else if a = 2 then 11 else if a = 8 then if b = 0 then 10 else if b = 10 then 8 else 0 else if a = 10 then 8 else 0 E0_subset_E1 := by decide t_mem_of_mem_E0' := by decide mem_2_of_mem_E0 := by decide eq_of_mem_E0 := by decide undef_of_not_mem_E0' := by decide strange := by decide @[equational_result]
|
def
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
initial
| null |
Equation65_facts : ∃ (G : Type) (_ : Magma G), Facts G [65] [614, 817, 1426, 3862, 4065] := by use ℕ, ⟨closure initial⟩ simp only [Equation65, closure_prop, implies_true, not_forall, true_and] split_ands repeat { use 0 nth_rw 4 [closure_eq_of_mem_e1 _ 0] nth_rw 3 [closure_eq_of_mem_e1 _ 0] nth_rw 2 [closure_eq_of_mem_e1 _ 0] nth_rw 1 [closure_eq_of_mem_e1 _ 0] · decide · decide · decide · decide · decide }
|
theorem
|
equational_theories
|
[
"import equational_theories.FactsSyntax",
"import equational_theories.EquationalResult",
"import Mathlib.Algebra.Order.Ring.Nat",
"import Mathlib.Logic.Denumerable",
"import Mathlib.Tactic.Recall",
"import equational_theories.Equations.Basic"
] |
equational_theories/Asterix.lean
|
Equation65_facts
| null |
ofMatrix {n : Nat} [Inhabited (Fin n)] (table : Array (Array (Fin n))) (x y : Fin n) : Fin n := table[x.val]![y.val]! /-- A 3x3 helper magma, A21, which streamlines the full construction. -/
|
def
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
ofMatrix
| null |
MagmaA21 : Magma (Fin 3) where op := memoFinOp (ofMatrix #[ #[0, 1, 2], #[0, 2, 1], #[0, 2, 1] ]) /-- We define Knuth's A2 here in terms of A21. -/
|
def
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
MagmaA21
|
/-- A 3x3 helper magma, A21, which streamlines the full construction. -/
|
MagmaA2 : Magma (Fin 3 × Fin 3) where op (p1 p2 : Fin 3 × Fin 3) : Fin 3 × Fin 3 := match p1, p2 with | (a, b), (⟨0, _⟩, _) => (MagmaA21.op a b, ⟨0, by decide⟩) | (_, b), (c, ⟨0, _⟩) => (b, MagmaA21.op b c) | (_, b), (c, _) => (b, c) /-- A magma isomorphic to A2, given as an optable. -/
|
def
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
MagmaA2
|
/-- We define Knuth's A2 here in terms of A21. -/
|
MagmaA2T : Magma (Fin 9) where op := memoFinOp (ofMatrix #[ #[0, 0, 0, 1, 1, 1, 2, 2, 2], #[3, 3, 3, 5, 4, 4, 4, 5, 5], #[6, 6, 6, 8, 7, 7, 7, 8, 8], #[0, 0, 0, 1, 1, 1, 2, 2, 2], #[6, 6, 6, 5, 4, 4, 4, 5, 5], #[3, 3, 3, 8, 7, 7, 7, 8, 8], #[0, 0, 0, 1, 1, 1, 2, 2, 2], #[6, 6, 6, 5, 4, 4, 4, 5, 5], #[3, 3, 3, 8, 7, 7, 7, 8, 8]]) /-- Fin 3 × Fin 3 is isomorphic to Fin 9 as a set. -/
|
def
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
MagmaA2T
|
/-- A magma isomorphic to A2, given as an optable. -/
|
equiv_F3xF3_F9 : (Fin 3 × Fin 3) ≃ (Fin 9) where toFun := fun (p : Fin 3 × Fin 3) => let a := p.1.val let b := p.2.val have ha : a < 3 := p.1.isLt have hb : b < 3 := p.2.isLt have h2a : b + 3 * a < 9 := by linarith Fin.mk (b + 3 * a) h2a invFun := fun (n : Fin 9) => let a := n.val / 3 let b := n.val % 3 have ha : a < 3 := Nat.div_lt_of_lt_mul (Fin.is_lt n) have hb : b < 3 := Nat.mod_lt n.val (by norm_num) (Fin.mk a ha, Fin.mk b hb) left_inv := fun (n : Fin 3 × Fin 3) => by match n with | (⟨0, _⟩, ⟨0, _⟩) | (⟨0, _⟩, ⟨1, _⟩) | (⟨0, _⟩, ⟨2, _⟩) | (⟨1, _⟩, ⟨0, _⟩) | (⟨1, _⟩, ⟨1, _⟩) | (⟨1, _⟩, ⟨2, _⟩) | (⟨2, _⟩, ⟨0, _⟩) | (⟨2, _⟩, ⟨1, _⟩) | (⟨2, _⟩, ⟨2, _⟩) => simp_all only [Nat.reduceMul, Nat.reduceAdd, Nat.reduceDiv, Fin.reduceFinMk, Nat.reduceMod, Fin.isValue] right_inv := fun (n : Fin 9) => by match n with | ⟨0, _⟩ | ⟨1, _⟩ | ⟨2, _⟩ | ⟨3, _⟩ | ⟨4, _⟩ | ⟨5, _⟩ | ⟨6, _⟩ | ⟨7, _⟩ | ⟨8, _⟩ => simp_all only [Nat.reduceMod, Nat.reduceDiv, Nat.reduceMul, Nat.reduceAdd, Fin.reduceFinMk] local instance : Magma (Fin 3 × Fin 3) := MagmaA2 local instance : Magma (Fin 9) := MagmaA2T
|
def
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
equiv_F3xF3_F9
|
/-- Fin 3 × Fin 3 is isomorphic to Fin 9 as a set. -/
|
equiv_MagmaA2_MagmaA2T : (Fin 3 × Fin 3) ≃◇ (Fin 9) where toEquiv := equiv_F3xF3_F9 map_op' := by intro x y match x with | (⟨n, _⟩, ⟨m, _⟩) => match y with | (⟨k, _⟩, ⟨l, _⟩) => match n, m, k, l with | 0, 0, 0, 0 | 0, 0, 0, 1 | 0, 0, 0, 2 | 0, 0, 1, 0 | 0, 0, 1, 1 | 0, 0, 1, 2 | 0, 0, 2, 0 | 0, 0, 2, 1 | 0, 0, 2, 2 | 0, 1, 0, 0 | 0, 1, 0, 1 | 0, 1, 0, 2 | 0, 1, 1, 0 | 0, 1, 1, 1 | 0, 1, 1, 2 | 0, 1, 2, 0 | 0, 1, 2, 1 | 0, 1, 2, 2 | 0, 2, 0, 0 | 0, 2, 0, 1 | 0, 2, 0, 2 | 0, 2, 1, 0 | 0, 2, 1, 1 | 0, 2, 1, 2 | 0, 2, 2, 0 | 0, 2, 2, 1 | 0, 2, 2, 2 | 1, 0, 0, 0 | 1, 0, 0, 1 | 1, 0, 0, 2 | 1, 0, 1, 0 | 1, 0, 1, 1 | 1, 0, 1, 2 | 1, 0, 2, 0 | 1, 0, 2, 1 | 1, 0, 2, 2 | 1, 1, 0, 0 | 1, 1, 0, 1 | 1, 1, 0, 2 | 1, 1, 1, 0 | 1, 1, 1, 1 | 1, 1, 1, 2 | 1, 1, 2, 0 | 1, 1, 2, 1 | 1, 1, 2, 2 | 1, 2, 0, 0 | 1, 2, 0, 1 | 1, 2, 0, 2 | 1, 2, 1, 0 | 1, 2, 1, 1 | 1, 2, 1, 2 | 1, 2, 2, 0 | 1, 2, 2, 1 | 1, 2, 2, 2 | 2, 0, 0, 0 | 2, 0, 0, 1 | 2, 0, 0, 2 | 2, 0, 1, 0 | 2, 0, 1, 1 | 2, 0, 1, 2 | 2, 0, 2, 0 | 2, 0, 2, 1 | 2, 0, 2, 2 | 2, 1, 0, 0 | 2, 1, 0, 1 | 2, 1, 0, 2 | 2, 1, 1, 0 | 2, 1, 1, 1 | 2, 1, 1, 2 | 2, 1, 2, 0 | 2, 1, 2, 1 | 2, 1, 2, 2 | 2, 2, 0, 0 | 2, 2, 0, 1 | 2, 2, 0, 2 | 2, 2, 1, 0 | 2, 2, 1, 1 | 2, 2, 1, 2 | 2, 2, 2, 0 | 2, 2, 2, 1 | 2, 2, 2, 2 => simp [equiv_F3xF3_F9] simp_all only [Nat.ofNat_pos, Nat.one_lt_ofNat, Fin.isValue] obtain ⟨_, _⟩ := x obtain ⟨_, _⟩ := y rfl @[equational_result]
|
def
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
equiv_MagmaA2_MagmaA2T
| null |
MagmaA2T.Facts : ∃ (G : Type) (_ : Magma G), Facts G [168, 1480, 1483, 1484, 1485, 1486, 1487, 2052, 2089, 2126, 2162, 2163, 2164] [3461, 3462, 3463, 3521, 3522, 3523, 3532, 3533, 3534, 3535, 3864, 3880, 3883, 3915, 3921, 3952, 3958, 3989, 3997, 4001, 4268, 4282, 4314, 4315, 4339, 4357, 4587, 4606, 4615, 4645, 4666, 4689] := ⟨Fin 9, MagmaA2T, by decideFin!⟩
|
theorem
|
equational_theories
|
[
"import equational_theories.Equations.All",
"import equational_theories.FactsSyntax",
"import equational_theories.MemoFinOp",
"import equational_theories.DecideBang",
"import equational_theories.Homomorphisms",
"import equational_theories.SmallMagmas",
"import Mathlib.Tactic.Linarith",
"import Mathlib.Tactic.NormNum"
] |
equational_theories/CentralGroupoids.lean
|
MagmaA2T.Facts
| null |
GraphEdge where lhs : String rhs : String deriving DecidableEq, Hashable, Lean.ToJson, Lean.FromJson
|
structure
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
GraphEdge
| null |
Edge | implication : GraphEdge → Edge | nonimplication : GraphEdge → Edge deriving DecidableEq, Hashable
|
inductive
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Edge
| null |
Edge.isTrue : Edge → Bool | .implication _ => true | .nonimplication _ => false
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Edge.isTrue
| null |
Edge.get : Edge → GraphEdge | .nonimplication x | .implication x => x
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Edge.get
| null |
Edge.lhs : Edge → String := GraphEdge.lhs ∘ get
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Edge.lhs
| null |
Edge.rhs : Edge → String := GraphEdge.rhs ∘ get
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Edge.rhs
| null |
Outcome /-- the implication has an explicit proof -/ | explicit_proof_true /-- the implication can be derived from proven theorems -/ | implicit_proof_true /-- the implication is explicitly conjectured -/ | explicit_conjecture_true /-- the implication can be derived from theorems and conjectures -/ | implicit_conjecture_true /-- the status of the implication is unknown -/ | unknown /-- the implication can be disproved from theorems and conjectures -/ | implicit_conjecture_false /-- the implication can is explicitly conjectured to be false -/ | explicit_conjecture_false /-- the falsity of the implication can be derived from proven theorems -/ | implicit_proof_false /-- the implication has an explicit disproof -/ | explicit_proof_false deriving Repr, DecidableEq, Hashable, Lean.ToJson, Lean.FromJson
|
inductive
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome
| null |
Outcome.implicit_theorem : Bool → Outcome | true => implicit_proof_true | false => implicit_proof_false
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.implicit_theorem
| null |
Outcome.explicit_theorem : Bool → Outcome | true => explicit_proof_true | false => explicit_proof_false
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.explicit_theorem
| null |
Outcome.implicit_conjecture : Bool → Outcome | true => implicit_conjecture_true | false => implicit_conjecture_false
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.implicit_conjecture
| null |
Outcome.explicit_conjecture : Bool → Outcome | true => explicit_conjecture_true | false => explicit_conjecture_false
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.explicit_conjecture
| null |
Outcome.isExplicit : Outcome → Bool | explicit_proof_true => true | implicit_proof_true => false | explicit_conjecture_true => true | implicit_conjecture_true => false | unknown => false | implicit_conjecture_false => false | explicit_conjecture_false => true | implicit_proof_false => false | explicit_proof_false => true
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.isExplicit
| null |
Outcome.isProven : Outcome → Bool | explicit_proof_true => true | implicit_proof_true => true | explicit_conjecture_true => false | implicit_conjecture_true => false | unknown => false | implicit_conjecture_false => false | explicit_conjecture_false => false | implicit_proof_false => true | explicit_proof_false => true
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.isProven
| null |
Outcome.isTrue : Outcome → Bool | explicit_proof_true => true | implicit_proof_true => true | explicit_conjecture_true => true | implicit_conjecture_true => true | unknown => false | implicit_conjecture_false => false | explicit_conjecture_false => false | implicit_proof_false => false | explicit_proof_false => false
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Outcome.isTrue
| null |
dfs1 (graph : Array (Array Nat)) (vertex : Nat) (vis : Array Bool) (order : Array Nat) : Array Bool × Array Nat := Id.run do let mut vis1 := vis.set! vertex true let mut ord := order for v in graph[vertex]! do unless vis1[v]! do (vis1, ord) := dfs1 graph v vis1 ord pure (vis1, ord.push vertex)
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
dfs1
| null |
dfs2 (graph : Array (Array Nat)) (vertex : Nat) (component : Array Nat) (component_id : Nat) : Array Nat := Id.run do let mut comp := component.set! vertex component_id for v in graph[vertex]! do if component[v]! == 0 then comp := dfs2 graph v comp component_id pure comp /-- This is a bitset (https://en.cppreference.com/w/cpp/utility/bitset). It represents an array of bits by directly packing them to UInt64, which makes some operations more efficient. This is also more space-efficient. -/
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
dfs2
| null |
Bitset := Array UInt64
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Bitset
|
/-- This is a bitset (https://en.cppreference.com/w/cpp/utility/bitset).
It represents an array of bits by directly packing them to UInt64, which makes some operations
more efficient. This is also more space-efficient. -/
|
Bitset.toArray : Bitset → Array UInt64 := id
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Bitset.toArray
|
/-- This is a bitset (https://en.cppreference.com/w/cpp/utility/bitset).
It represents an array of bits by directly packing them to UInt64, which makes some operations
more efficient. This is also more space-efficient. -/
|
Bitset.mk (n : Nat) : Bitset := Array.replicate ((n + 63) >>> 6) 0
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Bitset.mk
|
/-- This is a bitset (https://en.cppreference.com/w/cpp/utility/bitset).
It represents an array of bits by directly packing them to UInt64, which makes some operations
more efficient. This is also more space-efficient. -/
|
Bitset.set (b : Bitset) (n : Nat) : Bitset := b.modify (n >>> 6) (fun x ↦ x ||| (1 <<< ((UInt64.ofNat n) &&& 63)))
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Bitset.set
|
/-- This is a bitset (https://en.cppreference.com/w/cpp/utility/bitset).
It represents an array of bits by directly packing them to UInt64, which makes some operations
more efficient. This is also more space-efficient. -/
|
Bitset.get (b : Bitset) (n : Nat) : Bool := (b.toArray[n >>> 6]! >>> ((UInt64.ofNat n) &&& 63)) &&& 1 != 0
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Bitset.get
| null |
DenseNumbering (α : Type) [BEq α] [Hashable α] where in_order : Array α index : Std.HashMap α Nat
|
structure
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DenseNumbering
| null |
DenseNumbering.size {α : Type} [BEq α] [Hashable α] (num : DenseNumbering α) : Nat := num.in_order.size
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DenseNumbering.size
| null |
DenseNumbering.fromArray {α : Type} [BEq α] [Hashable α] (elts : Array α) : DenseNumbering α := let index := Std.HashMap.ofList (elts.mapIdx (fun i x => (x, i))).toList ⟨elts, index⟩
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DenseNumbering.fromArray
| null |
DenseNumbering.map {α β : Type} [BEq α] [BEq β] [Hashable α] [Hashable β] (num : DenseNumbering α) (f : α → β) : DenseNumbering β := DenseNumbering.fromArray (num.in_order.map f)
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DenseNumbering.map
| null |
ltEquationNames (a b : String) : Bool := assert! a.startsWith "Equation" assert! b.startsWith "Equation" let aNum := (a.toSubstring.drop 8).toNat?.get! let bNum := (b.toSubstring.drop 8).toNat?.get! aNum < bNum
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
ltEquationNames
| null |
equationSet (inp : Array EntryVariant) : Std.HashSet String := Id.run do let mut eqs : Std.HashSet String := {} for imp in inp do match imp with | .implication ⟨lhs, rhs, _⟩ => eqs := eqs.insert lhs eqs := eqs.insert rhs | .facts ⟨satisfied, refuted, _⟩ => for eq in satisfied ++ refuted do eqs := eqs.insert eq | .unconditional eq => eqs := eqs.insert eq pure eqs
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
equationSet
| null |
number_equations (inp : Array EntryVariant) : DenseNumbering String := -- number the equations for easier processing DenseNumbering.fromArray ((equationSet inp).toArray.qsort ltEquationNames) /-- This transforms the `Facts` in the input array to `Edge`s -/
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
number_equations
| null |
toEdges (inp : Array EntryVariant) : Array Edge := Id.run do let eqs := number_equations inp let mut edges : Array Edge := Array.mkEmpty inp.size let mut nonimplies : Array Bitset := Array.replicate eqs.size (Bitset.mk eqs.size) for imp in inp do match imp with | .implication ⟨lhs, rhs, _⟩ => edges := edges.push (.implication ⟨lhs, rhs⟩) | .facts ⟨satisfied, refuted, _⟩ => for f1 in satisfied do for f2 in refuted do nonimplies := nonimplies.modify eqs[f1]! (fun x ↦ x.set eqs[f2]!) | _ => continue for hi : i in [:eqs.size] do for hj : j in [:eqs.size] do if nonimplies[i]!.get j then edges := edges.push (.nonimplication ⟨eqs.in_order[i], eqs.in_order[j]⟩) return edges
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
toEdges
|
/--
This transforms the `Facts` in the input array to `Edge`s
-/
|
Reachability where size : Nat reachable : Array Bitset components : Array (Array Nat)
|
structure
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
Reachability
| null |
closure_aux (inp : Array EntryVariant) (duals: Std.HashMap Nat Nat) (eqs : DenseNumbering String) : IO Reachability := do -- construct the implication/non-implication graph let n := eqs.size let mut graph_size := 2 * n let mut graph : Array (Array Nat) := Array.replicate graph_size #[] let mut revgraph : Array (Array Nat) := Array.replicate graph_size #[] for imp in inp do match imp with | .implication imp => graph := graph.modify (eqs[imp.rhs]!) (fun x => x.push eqs[imp.lhs]!) graph := graph.modify (eqs[imp.rhs]! + n) (fun x => x.push (eqs[imp.lhs]! + n)) revgraph := revgraph.modify (eqs[imp.lhs]!) (fun x => x.push eqs[imp.rhs]!) revgraph := revgraph.modify (eqs[imp.lhs]! + n) (fun x => x.push (eqs[imp.rhs]! + n)) | .facts ⟨satisfied, refuted, _⟩ => if satisfied.size * refuted.size < satisfied.size + refuted.size + 1 then for lhs in satisfied do for rhs in refuted do graph := graph.modify (eqs[lhs]!) (fun x => x.push (eqs[rhs]! + n)) revgraph := revgraph.modify (eqs[rhs]! + n) (fun x => x.push eqs[lhs]!) else let dummy := graph_size graph_size := graph_size + 2 graph := graph.push (refuted.map (eqs[·]! + n)) revgraph := revgraph.push (satisfied.map (eqs[·]!)) -- this is for the dual implications graph := graph.push #[] revgraph := revgraph.push #[] for f1 in satisfied do graph := graph.modify eqs[f1]! (fun x ↦ x.push dummy) for f1 in refuted do revgraph := revgraph.modify (eqs[f1]! + n) (fun x ↦ x.push dummy) | _ => pure () let duals := Array.ofFn λ (i: Fin graph_size) ↦ if i < n then duals.getD i i else if i < 2 * n then n + duals.getD (i - n) (i - n) else i ^^^ 1 for i in [0:graph_size], neighbors in graph do let i' := duals[i]! for j in neighbors do let j' := duals[j]! if i != i' ∨ j != j' then graph := graph.modify i' (fun x => x.push j') revgraph := revgraph.modify j' (fun x => x.push i') let mut vis : Array Bool := Array.replicate graph_size false let mut order : Array Nat := Array.mkEmpty graph_size -- compute strongly connected components and the condensation graph using Kosaraju's algorithm for i in [:graph_size] do unless vis[i]! do (vis, order) := dfs1 graph i vis order order := order.reverse let mut component : Array Nat := Array.replicate graph_size 0 let mut last_component : Nat := 0 for i in order do if component[i]! == 0 then do last_component := last_component + 1 component := dfs2 revgraph i component last_component let mut components : Array (Array Nat) := Array.replicate last_component #[] let mut comp_graph : Array (Std.HashSet Nat) := Array.replicate last_component {} for i in [:graph_size] do components := components.modify (component[i]!-1) (fun x ↦ x.push i) for j in graph[i]! do unless component[i]! == component[j]! do comp_graph := comp_graph.modify (component[i]!-1) (fun x ↦ x.insert (component[j]!-1)) -- Run bitset transitive closure on the condensation graph let mut reachable : Array Bitset := Array.replicate last_component (Bitset.mk last_component) for i_ in [:last_component] do let i := last_component - 1 - i_ reachable := reachable.modify i (fun x ↦ x.set i) for j in comp_graph[i]! do reachable := reachable.modify i (fun x ↦ x.mapIdx (fun idx val ↦ reachable[j]!.toArray[idx]! ||| val)) if components[i]![0]! < n && reachable[i]!.get (component[components[i]![0]! + n]!-1) then throw (IO.userError "Inconsistent conjectures!") pure ⟨n, reachable, components⟩
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
closure_aux
| null |
number_duals (duals: Std.HashMap String String) (eqs: DenseNumbering String) := Std.HashMap.ofList <| duals.toList.map (λ (i, j) ↦ (eqs[i]!, eqs[j]!)) /-- This computes the closure of the implications/non-implications represented by `inp`. -/
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
number_duals
| null |
closure (inp : Array EntryVariant) (duals: Std.HashMap String String) : IO (Array Edge) := do let eqs := number_equations inp let n := eqs.size let duals := number_duals duals eqs -- extract the implications let mut ans : Array Edge := Array.mkEmpty (n*n) for ⟨x, y, is_true⟩ in ← closure_aux inp duals eqs do unless x == y do if is_true then ans := ans.push (.implication ⟨eqs.in_order[x]!, eqs.in_order[y]!⟩) else ans := ans.push (.nonimplication ⟨eqs.in_order[x]!, eqs.in_order[y]!⟩) pure ans
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
closure
|
/--
This computes the closure of the implications/non-implications represented by `inp`.
-/
|
list_outcomes (res : Array Entry) (duals: Std.HashMap String String): IO (Array String × Array (Array Outcome)) := do let rs := res.map (·.variant) let prs := res.filter (·.proven) |>.map (·.variant) let eqs := number_equations rs let duals := number_duals duals eqs let n := eqs.size let mut outcomes : Array (Array Outcome) := Array.replicate n (Array.replicate n .unknown) for edge in toEdges prs do outcomes := outcomes.modify eqs[edge.lhs]! (fun a ↦ a.set! eqs[edge.rhs]! (.explicit_theorem edge.isTrue)) for ⟨x, y, is_true⟩ in ← closure_aux prs duals eqs do outcomes := outcomes.modify x (fun a ↦ a.modify y fun y ↦ if y = .unknown then .implicit_theorem is_true else y) for edge in toEdges rs do outcomes := outcomes.modify eqs[edge.lhs]! (fun a ↦ a.modify eqs[edge.rhs]! fun y ↦ if y = .unknown then .explicit_conjecture edge.isTrue else y) for ⟨x, y, is_true⟩ in ← closure_aux rs duals eqs do outcomes := outcomes.modify x (fun a ↦ a.modify y fun y ↦ if y = .unknown then .implicit_conjecture is_true else y) return (eqs.in_order, outcomes)
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
list_outcomes
| null |
outcomes_mod_equiv (inp : Array EntryVariant) (duals: Std.HashMap String String) : IO (DenseNumbering (Array String) × Array (Array (Option Bool))) := do let eqs := number_equations inp let n := eqs.size let duals := number_duals duals eqs let reachable ← closure_aux inp duals eqs let comps := reachable.components.filter (·[0]! < n) |> DenseNumbering.fromArray let mut implies : Array (Array (Option Bool)) := Array.replicate comps.size (Array.replicate comps.size none) for i in reachable.components, i2 in reachable.reachable do if i[0]! >= reachable.size then continue for j in reachable.components, j2 in [:reachable.components.size] do if i2.get j2 then if j[0]! < n then implies := implies.modify comps[j]! (fun x ↦ x.set! comps[i]! true) else if j.back! < 2*n then implies := implies.modify comps[i]! (fun x ↦ x.set! comps[j.map (·-n)]! false) return (comps.map (fun ids => ids.map (eqs.in_order[·]!)), implies) section DualityRelation
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
outcomes_mod_equiv
| null |
DualityRelation where dualEquations : Std.HashMap String String
|
structure
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DualityRelation
| null |
DualityRelation.ofFile (path : String) : IO DualityRelation := do let dualsJson := Json.parse (←IO.FS.readFile path) |>.toOption.get! let mut dualEquations : Std.HashMap String String := {} for pair in dualsJson.getArr?.toOption.get! do let a := s!"Equation{pair.getArr?.toOption.get![0]!.getNat?.toOption.get!}" let b := s!"Equation{pair.getArr?.toOption.get![1]!.getNat?.toOption.get!}" dualEquations := dualEquations.insert a b dualEquations := dualEquations.insert b a pure ⟨dualEquations⟩
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DualityRelation.ofFile
| null |
DualityRelation.dual (rel : DualityRelation) (imp : GraphEdge) : Option GraphEdge := if isCoreEquationName imp.lhs && isCoreEquationName imp.rhs then some ⟨rel.dualEquations.getD imp.lhs imp.lhs, rel.dualEquations.getD imp.rhs imp.rhs⟩ else none
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
DualityRelation.dual
| null |
getStoredDualityRelations := DualityRelation.ofFile "data/duals.json"
|
def
|
equational_theories
|
[
"import equational_theories.EquationalResult"
] |
equational_theories/Closure.lean
|
getStoredDualityRelations
| null |
derive.getAxioms {α} [DecidableEq α] {Γ : Ctx α} {E : MagmaLaw α} (h : Γ ⊢ E) : Finset (MagmaLaw α) := match h with | .Ax _ => {E} | .Ref => {} | .Sym h => derive.getAxioms h | .Trans h₁ h₂ => derive.getAxioms h₁ ∪ derive.getAxioms h₂ | .Subst _ h => derive.getAxioms h | .Cong h₁ h₂ => derive.getAxioms h₁ ∪ derive.getAxioms h₂
|
def
|
equational_theories
|
[
"import Mathlib.Data.Finset.Basic",
"import equational_theories.Completeness"
] |
equational_theories/Compactness.lean
|
derive.getAxioms
| null |
ToCtx {α} (S : Finset (MagmaLaw α)) : Ctx α := S
|
def
|
equational_theories
|
[
"import Mathlib.Data.Finset.Basic",
"import equational_theories.Completeness"
] |
equational_theories/Compactness.lean
|
ToCtx
| null |
Ctx.hasSubset {α} : HasSubset (Ctx α) := Set.instHasSubset
|
instance
|
equational_theories
|
[
"import Mathlib.Data.Finset.Basic",
"import equational_theories.Completeness"
] |
equational_theories/Compactness.lean
|
Ctx.hasSubset
| null |
derive.Weak {α} {Γ Δ : Ctx α} {E : MagmaLaw α} (inc : Γ ⊆ Δ) (h : Γ ⊢ E) : Δ ⊢ E := by cases h case Ax => refine derive.Ax (inc ?_); assumption case Ref => exact derive.Ref case Sym => apply derive.Sym ; apply derive.Weak _ <;> trivial case Trans => apply derive.Trans <;> try apply derive.Weak <;> assumption case Subst => apply derive.Subst ; apply derive.Weak <;> assumption case Cong => apply derive.Cong <;> apply derive.Weak <;> assumption
|
def
|
equational_theories
|
[
"import Mathlib.Data.Finset.Basic",
"import equational_theories.Completeness"
] |
equational_theories/Compactness.lean
|
derive.Weak
| null |
derive.getAxiomsEnough {α} [DecidableEq α] {Γ : Ctx α} {E : MagmaLaw α} (h : Γ ⊢ E) : ToCtx (derive.getAxioms h) ⊢ E := by cases h <;> simp [ToCtx, getAxioms] case Ax => constructor; rfl case Ref => exact derive.Ref case Sym _ _ h => exact derive.Sym (derive.getAxiomsEnough _) case Trans _ _ _ h₁ h₂ => apply derive.Trans · exact derive.Weak Set.subset_union_left (derive.getAxiomsEnough h₁) · exact derive.Weak Set.subset_union_right (derive.getAxiomsEnough h₂) case Subst => exact derive.Subst _ (derive.getAxiomsEnough _) case Cong _ _ _ h₁ h₂ => exact derive.Cong (derive.Weak Set.subset_union_left (derive.getAxiomsEnough h₁)) (derive.Weak Set.subset_union_right (derive.getAxiomsEnough h₂))
|
def
|
equational_theories
|
[
"import Mathlib.Data.Finset.Basic",
"import equational_theories.Completeness"
] |
equational_theories/Compactness.lean
|
derive.getAxiomsEnough
| null |
Compactness {α} [DecidableEq α] {Γ : Ctx α} {E : MagmaLaw α} (h : Γ ⊧ E) : ∃ (Δ : Finset (MagmaLaw α)), Nonempty <| ToCtx Δ ⊧ E := by have ⟨h''⟩ := Completeness h exact ⟨derive.getAxioms h'', ⟨Soundness (derive.getAxiomsEnough _)⟩⟩
|
def
|
equational_theories
|
[
"import Mathlib.Data.Finset.Basic",
"import equational_theories.Completeness"
] |
equational_theories/Compactness.lean
|
Compactness
| null |
Structured dataset from equational_theories — Terence Tao's magma equations project.
14,379 declarations extracted from Lean 4 source files.
| Column | Type | Description |
|---|---|---|
| fact | string | Declaration body |
| type | string | theorem, def, lemma, etc. |
| library | string | Source module |
| imports | list | Required imports |
| filename | string | Source file path |
| symbolic_name | string | Identifier |
| docstring | string | Documentation (if present) |