-3

I wanted to prove group properties over integer. I found the setoid representation of integer makes proof easy.

is defined as (ℕ , ℕ) such that (a , b) represents a - b

zero : ℤ
zero = 0 , 0

I have already proven

leftIdZ : (a : ℤ) → zero + a ≡ a
rightIdZ : (a : ℤ) → a + zero ≡ a

zpre and zsuc is defined as

zsuc : ℤ → ℤ
zsuc (m , n) = suc m , n

zpre : ℤ → ℤ
zpre (m , n) = m , suc n

I would like to prove the commutativity of addition:

commZ-+ : (a b : ℤ) → a + b ≡ b + a
commZ-+ (ℕ.zero , ℕ.zero) b = sym (trans (rightIdZ b) (sym (leftIdZ b)))
commZ-+ (ℕ.zero , suc x₁) (ℕ.zero , ℕ.zero) = rightIdZ (ℕ.zero , suc x₁)
commZ-+ (ℕ.zero , suc x₁) (ℕ.zero , suc x₃) = cong zpre {!!}
commZ-+ (ℕ.zero , suc x₁) (suc x₂ , x₃) = cong zsuc {!!}
commZ-+ (suc x , x₁) (x₂ , x₃) = {!!}

I found somewhere they are proving this by using agda library. But i tried in that way (above).

The problem reduced to proof 0 , (x₁ ℕ.+ suc x₃) ≡ 0 , (x₃ ℕ.+ suc x₁)

I had proof of this lemma : lemma-+succ : ∀ a b → suc a + b ≡ a + suc b I know some how this lemma will be used to prove above reduced goal but it return type is Set whereas above that is expecting integer.

Is there any efficient way of doing this?? or How should i do this?? Please help.

Cactus
  • 27,075
  • 9
  • 69
  • 149
ajayv
  • 641
  • 6
  • 21

1 Answers1

1

Your problem description can be simplified to defining problem in the following code:

open import Data.Product
open import Data.Nat as ℕ
open import Relation.Binary.PropositionalEquality

postulate lemma-+succ : ∀ a b → suc a ℕ.+ b ≡ a ℕ.+ suc b

problem : ∀ x₁ x₃ → 0 ,′ (x₁ ℕ.+ suc x₃) ≡ 0 ,′ (x₃ ℕ.+ suc x₁)
problem = ?

First of all, let's get rid of that 0, part: if x ≡ y, then 0, x ≡ 0, y by simple congruence:

problem : ∀ x₁ x₃ → 0 ,′ (x₁ ℕ.+ suc x₃) ≡ 0 ,′ (x₃ ℕ.+ suc x₁)
problem x₁ x₃ = cong (λ y → 0 , y) ?

So that leaves us with just the commutativity of natural addition: the type of the hole is x₁ + suc x₃ ≡ x₃ + suc x₁.

This should give you enough hints to finish what you are trying to do: lemma-+succ is not directly applicable; can you prove lemma-+comm : ∀ a b → a ℕ.+ b ≡ b ℕ.+ a?

Cactus
  • 27,075
  • 9
  • 69
  • 149
  • Now I get that if any of side is equal I can reduced it by using lambda expression. But what if we can not reduce it for example. `x₂ , (x₁ ℕ.+ 0) ≡ (x₂ ℕ.+ 0) , x₁.` Here I have proof of each part seperately but i am not able to use cong here. – ajayv Dec 29 '15 at 07:46
  • So you've looked at [`cong`](https://agda.github.io/agda-stdlib/Relation.Binary.PropositionalEquality.html#1036) but didn't find [`cong₂`](https://agda.github.io/agda-stdlib/Relation.Binary.PropositionalEquality.html#1274) right next to it? – Cactus Dec 29 '15 at 07:50
  • Also, even if `cong₂` didn't exist, you could use `trans`itivity to go from `x₂ , (x₁ ℕ.+ 0)` to `x₂ , x₁` to `(x₂ ℕ.+ 0) , x₁`. – Cactus Dec 29 '15 at 07:51