6. Require
Import
Setoid.
Require
Import
Relation_Definitions.
Require
Import
Arith.
Require
Import
Compare_dec.
Require
Import
Omega.
Inductive
Z'
:
Set
:=
|
mkZ'
:
nat
-‐>
nat
-‐>
Z'.
Definition
Z'eq
(z
z':Z')
:
Prop
:=
let
(a,b)
:=
z
in
let
(c,d)
:=
z'
in
a
+
d
=
b
+
c.
Notation
"a
=Z=
b"
:=
(Z'eq
a
b)
(at
level
70).
8. (*
Z’
*)
Definition
Z'plus
(z
z':Z')
:
Z'
:=
let
(a,b)
:=
z
in
let
(c,d)
:=
z'
in
mkZ'
(a+c)
(b+d).
(*
Z’plus
Z’
Z’eq
well-‐defined
x
=Z=
y
-‐>
x0
=Z=
y0
-‐>
Z'plus
x
x0
=Z=
Z'plus
y
y0
.
*)
Add
Parametric
Morphism
:
Z'plus
with
signature
Z'eq
==>
Z'eq
==>
Z'eq
as
Z'_plus_mor.
Proof.
Qed.
9. (*
*)
Lemma
Z'eq_plus_id_l
:
forall
z
a,
Z'plus
(mkZ'
a
a)
z
=Z=
z.
Lemma
Z'eq_plus_comm
:
forall
z
z',
Z'plus
z
z'
=Z=
Z'plus
z'
z.
(*
rewrite
setoid_rewrite
*)
Lemma
Z'eq_plus_id_r
:
forall
z
a,
Z'plus
z
(mkZ'
a
a)
=Z=
z.
Proof.
intros.
setoid_rewrite
(Z'eq_plus_comm
z
(mkZ'
a
a)).
apply
Z'eq_plus_id_l.
Qed.
(*
tactic
setoid_reflexivity,
setoid_rewrite,
setoid_replace
*)