pith. machine review for the scientific record. sign in
def

ofLogicNat

definition
show as:
view math explainer →
module
IndisputableMonolith.Foundation.IntegersFromLogic
domain
Foundation
line
98 · github
papers citing
none yet

open explainer

Read the cached plain-language explainer.

open lean source

IndisputableMonolith.Foundation.IntegersFromLogic on GitHub at line 98.

browse module

All declarations in this module, on Recognition.

explainer page

A cached Ask Recognition explainer exists for this declaration.

open explainer

depends on

used by

formal source

  95
  96/-- The natural injection `LogicNat ↪ LogicInt` sending `n` to `[n, 0]`.
  97This is the inclusion of the additive monoid into its Grothendieck group. -/
  98def ofLogicNat (n : LogicNat) : LogicInt := mk n LogicNat.zero
  99
 100@[simp] theorem ofLogicNat_zero : ofLogicNat LogicNat.zero = mk LogicNat.zero LogicNat.zero := rfl
 101
 102/-! ## 4. Zero, One, Negation, Addition, Multiplication -/
 103
 104/-- Zero in `LogicInt`. -/
 105def zero : LogicInt := mk LogicNat.zero LogicNat.zero
 106
 107/-- One in `LogicInt`. -/
 108def one : LogicInt := mk (LogicNat.succ LogicNat.zero) LogicNat.zero
 109
 110instance : Zero LogicInt := ⟨zero⟩
 111instance : One LogicInt := ⟨one⟩
 112
 113/-- Negation: `-(a, b) = (b, a)`. -/
 114def neg : LogicInt → LogicInt :=
 115  Quotient.lift (fun (p : LogicNat × LogicNat) => mk p.2 p.1) (by
 116    rintro ⟨a, b⟩ ⟨c, d⟩ h
 117    show mk b a = mk d c
 118    apply sound
 119    show b + c = d + a
 120    rw [eq_iff_toNat_eq, toNat_add, toNat_add]
 121    have h' : toNat a + toNat d = toNat c + toNat b := by
 122      have := congrArg toNat (show a + d = c + b from h)
 123      rwa [toNat_add, toNat_add] at this
 124    omega)
 125
 126instance : Neg LogicInt := ⟨neg⟩
 127
 128/-- Addition: `(a, b) + (c, d) = (a + c, b + d)`. -/