|
| 1 | +/- |
| 2 | +Copyright (c) 2021 Johan Commelin. |
| 3 | +All rights reserved. |
| 4 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 5 | +Authors: Johan Commelin, Damiano Testa, Kevin Buzzard |
| 6 | +
|
| 7 | +! This file was ported from Lean 3 source module linear_order_with_pos_mul_pos_eq_zero |
| 8 | +! leanprover-community/mathlib commit 328375597f2c0dd00522d9c2e5a33b6a6128feeb |
| 9 | +! Please do not edit these lines, except to modify the commit id |
| 10 | +! if you have ported upstream changes. |
| 11 | +-/ |
| 12 | +import Mathlib.Algebra.Order.Monoid.Defs |
| 13 | +import Mathlib.Algebra.Order.Monoid.WithZero.Defs |
| 14 | + |
| 15 | +/-! |
| 16 | +An example of a `LinearOrderedCommMonoidWithZero` in which the product of two positive |
| 17 | +elements vanishes. |
| 18 | +
|
| 19 | +This is the monoid with 3 elements `0, ε, 1` where `ε ^ 2 = 0` and everything else is forced. |
| 20 | +The order is `0 < ε < 1`. Since `ε ^ 2 = 0`, the product of strictly positive elements can vanish. |
| 21 | +
|
| 22 | +Relevant Zulip chat: |
| 23 | +https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/mul_pos |
| 24 | +-/ |
| 25 | + |
| 26 | + |
| 27 | +namespace Counterexample |
| 28 | + |
| 29 | +/-- The three element monoid. -/ |
| 30 | +inductive Foo |
| 31 | + | zero |
| 32 | + | eps |
| 33 | + | one |
| 34 | + deriving DecidableEq |
| 35 | +#align counterexample.foo Counterexample.Foo |
| 36 | + |
| 37 | +namespace Foo |
| 38 | + |
| 39 | +instance inhabited : Inhabited Foo := |
| 40 | + ⟨zero⟩ |
| 41 | +#align counterexample.foo.inhabited Counterexample.Foo.inhabited |
| 42 | + |
| 43 | +instance : Zero Foo := |
| 44 | + ⟨zero⟩ |
| 45 | + |
| 46 | +instance : One Foo := |
| 47 | + ⟨one⟩ |
| 48 | + |
| 49 | +local notation "ε" => eps |
| 50 | + |
| 51 | +/-- The order on `Foo` is the one induced by the natural order on the image of `aux1`. -/ |
| 52 | +def aux1 : Foo → ℕ |
| 53 | + | 0 => 0 |
| 54 | + | ε => 1 |
| 55 | + | 1 => 2 |
| 56 | +#align counterexample.foo.aux1 Counterexample.Foo.aux1 |
| 57 | + |
| 58 | +/-- A tactic to prove facts by cases. -/ |
| 59 | +macro (name := boom) "boom" : tactic => `(tactic| (repeat' rintro ⟨⟩) <;> decide) |
| 60 | +#align counterexample.foo.boom Counterexample.Foo.boom |
| 61 | + |
| 62 | +theorem aux1_inj : Function.Injective aux1 := by boom |
| 63 | +#align counterexample.foo.aux1_inj Counterexample.Foo.aux1_inj |
| 64 | + |
| 65 | +instance linearOrder : LinearOrder Foo := |
| 66 | + LinearOrder.lift' aux1 aux1_inj |
| 67 | + |
| 68 | +/-- Multiplication on `Foo`: the only external input is that `ε ^ 2 = 0`. -/ |
| 69 | +def mul : Foo → Foo → Foo |
| 70 | + | 1, x => x |
| 71 | + | x, 1 => x |
| 72 | + | _, _ => 0 |
| 73 | +#align counterexample.foo.mul Counterexample.Foo.mul |
| 74 | + |
| 75 | +instance commMonoid : CommMonoid Foo where |
| 76 | + mul := mul |
| 77 | + one := 1 |
| 78 | + one_mul := by boom |
| 79 | + mul_one := by boom |
| 80 | + mul_comm := by boom |
| 81 | + mul_assoc := by boom |
| 82 | + |
| 83 | +instance : LinearOrderedCommMonoidWithZero Foo := |
| 84 | + { Foo.linearOrder, Foo.commMonoid with |
| 85 | + zero := 0 |
| 86 | + zero_mul := by boom |
| 87 | + mul_zero := by boom |
| 88 | + mul_le_mul_left := by rintro ⟨⟩ ⟨⟩ h ⟨⟩ <;> revert h <;> decide |
| 89 | + zero_le_one := by decide } |
| 90 | + |
| 91 | +theorem not_mul_pos : ¬∀ {M : Type} [LinearOrderedCommMonoidWithZero M], |
| 92 | + ∀ (a b : M) (_ : 0 < a) (_ : 0 < b), 0 < a * b := by |
| 93 | + intro h |
| 94 | + specialize h ε ε (by boom) (by boom) |
| 95 | + exact (lt_irrefl 0 (h.trans_le (by boom))).elim |
| 96 | +#align counterexample.foo.not_mul_pos Counterexample.Foo.not_mul_pos |
| 97 | + |
| 98 | +example : 0 < ε ∧ ε * ε = 0 := by boom |
| 99 | + |
| 100 | +end Foo |
| 101 | + |
| 102 | +end Counterexample |
0 commit comments