You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Coq.Reals.Raxioms定义的实数上使用Ssreflect引理?

Using MathComp's ssralg with Coq's Standard Reals

Great question! Let's walk through your needs and the solutions available:

Do you need to prove all structures from eqType up to ClosedReals?

Yes, you do. The ssralg.GRing.Ring operations (and the Num.real_closed_axiom) rely on a layered hierarchy of algebraic structures defined in MathComp:

  • Start with eqType (for foundational equality reasoning)
  • Then choiceType (to support choice principles required for some algebraic constructions)
  • Followed by zmoduleType, ringType, fieldType
  • Finally, realClosedFieldType (to meet the requirements of real_closed_axiom)

Coq's standard library real numbers (Rdefinitions.R) don't come with these MathComp-style structure instances out of the box, so you either need to implement them yourself or use existing, battle-tested implementations.

Are there ready-made implementations?

Absolutely! The mathcomp-analysis library (a companion to MathComp for formal analysis) provides full bridge instances between Coq's standard R and MathComp's algebraic hierarchy.

Once you import the right modules, you can directly use ssralg's add, mul, and other ring operations on R, and leverage Num.real_closed_axiom without writing any manual proofs. Here's a quick example:

From mathcomp Require Import all_ssreflect all_algebra.
From mathcomp.analysis Require Import realstruct.

(* Use ssralg operations on standard reals directly *)
Lemma add_comm (x y : R) : add x y = add y x.
Proof. by apply addC. Qed.

(* Access real closed field properties via Num.real_closed_axiom *)
Lemma real_closed_poly (P : {poly R}) :
  exists x : R, poly_eval P x = 0 \/ (forall x : R, poly_eval P x > 0) \/ (forall x : R, poly_eval P x < 0).
Proof. by apply real_closed_axiom. Qed.

This library handles all the tedious instance proofs for you, from eqType all the way up to realClosedFieldType.

Are there alternative approaches?

If you don't want to depend on mathcomp-analysis, you could manually implement each structure instance, but this is extremely time-consuming and error-prone:

  1. Define the eqType instance for R using Coq's built-in equality on reals.
  2. Add a choiceType instance (using classical logic, since Coq's standard R is built on classical reasoning).
  3. Prove the axioms for zmoduleType, ringType, and fieldType by linking Coq's real operations (Rplus, Rmult, etc.) to MathComp's add, mul, etc.
  4. Finally, prove the real closed field axioms to satisfy real_closed_axiom.

This manual route is not recommended unless you have very specific constraints—reusing mathcomp-analysis is almost always the smarter choice.

A quick note: Make sure you're using compatible versions of Coq, MathComp, and mathcomp-analysis to avoid version mismatch issues.

内容的提问来源于stack exchange,提问作者larsr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:12:50