Skip to Content.
Sympa Menu

coq-club - [Coq-Club] How to create a ring with a custom

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] How to create a ring with a custom


Chronological Thread 
  • From: Bill Wang <dramforever AT live.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: [Coq-Club] How to create a ring with a custom
  • Date: Sun, 7 Feb 2016 12:18:11 +0000
  • Accept-language: en-US
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=dramforever AT live.com; spf=Pass smtp.mailfrom=dramforever AT live.com; spf=None smtp.helo=postmaster AT BAY004-OMC1S27.hotmail.com
  • Ironport-phdr: 9a23:o6BuVBcN5PPi46qnyDmbBDFBlGMj4u6mDksu8pMizoh2WeGdxc6/YR7h7PlgxGXEQZ/co6odzbGG7Oa6BCdbvd6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDtvceOKF4UzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IAu3GePFyRrtBST8iLmod5cvxtBCFQxHFri8XVXxTmR5VCSDE6gv7V9H/qH2pmPB63XywPMnyBY89Xzvqu6txQRrmjz0KKTMj2GXWlME2h6Ve9kHy7ydjypLZNdnGfMF1ebnQKIsX
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:23

Hello coq-club,

I'm trying to add a ring of types up to isomorphism, but I cannot seem to get
coq to understand that iso is indeed a setoid, despite having done "Add
Parametric Relation". The error given is "cannot find setoid relation".

My code is pasted below. Can you help me fix it? Thanks.


(* I'm using coq 8.5 *)
Require Export Setoid Ring Ring_theory.

(* iso A B: Types A and B are isomorphic *)
Definition iso (A B : Type) : Prop :=
exists (fw : A -> B) (bw : B -> A),
(forall x, fw (bw x) = x) /\ (forall x, bw (fw x) = x).

(* Tactic iso for automagically solving (some) iso A B goals *)
Ltac de_iso := match goal with
| [ H : iso _ _ |- _ ] =>
let fw := fresh "fw" in
let bw := fresh "bw" in
let fw_bw := fresh "fw_bw" in
let bw_fw := fresh "bw_fw" in
destruct H as [fw [bw [fw_bw bw_fw]]]; de_iso
| _ => idtac
end.

Ltac simpl_goal := match goal with
| [ H : unit |- _ ] => destruct H; simpl_goal
| _ => dintuition
end.

Ltac work_iso := dintuition; simpl; simpl_goal; congruence.

Ltac mk_iso :=
match goal with
|- iso ?A ?B =>
refine (@ex_intro (A -> B) _ (ltac:(intuition))
(@ex_intro (B -> A) _ (ltac:(intuition))
(conj _ _)))
end.

Ltac iso := dintuition; de_iso; mk_iso; work_iso.

(* The actual relations *)
Add Parametric Relation : Type iso
reflexivity proved by ltac:(unfold Reflexive; iso)
symmetry proved by ltac:(unfold Symmetric; iso)
transitivity proved by ltac:(unfold Transitive; iso)
as iso_rel.

Add Parametric Morphism : sum
with signature iso ==> iso ==> iso as sum_mor.
iso. Defined.

Add Parametric Morphism : prod
with signature iso ==> iso ==> iso as prod_mor.
iso. Defined.

Definition iso_ring_theory : semi_ring_theory Empty_set unit sum prod iso.
iso. Defined.

(* This one does not work, but I don't know why *)
Add Ring iso_ring : iso_ring_theory.
(* Error: cannot find setoid relation *)



Archive powered by MHonArc 2.6.18.

Top of Page