Coq坐标

Coq坐标,coq,Coq,我很抱歉,如果这是明显张贴在某处,但我一直在尝试谷歌搜索,所以搜索,并没有找到任何关于这一点 A部分。 是否有一个标准库用于定义Coq中R^2和R^3中的坐标/向量和点?我非常想做一些标准的事情,比如添加向量、叉积、缩放等等 如果没有,这是如何开始的: Require Import Coq.Reals.Reals. Inductive Coordinate2 : Type := Point2: R -> R -> Coordinate2. Definition R2plus (u

我很抱歉,如果这是明显张贴在某处,但我一直在尝试谷歌搜索,所以搜索,并没有找到任何关于这一点

A部分。

是否有一个标准库用于定义Coq中R^2和R^3中的坐标/向量和点?我非常想做一些标准的事情,比如添加向量、叉积、缩放等等

如果没有,这是如何开始的:

Require Import Coq.Reals.Reals.

Inductive Coordinate2 : Type := Point2: R -> R -> Coordinate2.

Definition R2plus (u:Coordinate2) (v:Coordinate2) : Coordinate2 :=
match u, v with
 | (Point2 ux uy),(Point2 vx vy)=>(Point2 ((ux+vx)%R) ((uy+vy)%R))
end.  

(* etc. *)

Notation "x + y" := (R2plus x y).
还有,为什么我跑步时:

Eval compute in ((2%R) < (3%R))%R.
还是什么

B部分。


这是个好主意吗?我想建立一个用实数计算某些事情的算法,并在Coq中证明该算法的正确性。Coq.Reals.Reals是正确使用的东西,还是它真的太抽象了?

你也可以使用
(R*R)%type
list R
,或者
t2
,而
向量
中定义的
tan
,是一个大小
n
的列表

您可能希望为您的符号指定一个范围和一个定界键,以避免与其他符号发生冲突

Notation "x + y" := (R2plus x y) : r2_scope.
Delimit Scope r2_scope with R2.
Eval compute in ((Point2 0 1) + (Point2 2 3))%R2.
Prop
Set
Type
是排序,这意味着可以归纳地定义
Prop
类型的东西

例如,对于
nat
s,
le
被定义为

Inductive le : nat -> nat -> Prop :=
  | le_n : forall n, le n n
  | le_S : forall n m : nat, le n m -> le n (S m).
  • 2
    
    Notation "x + y" := (R2plus x y) : r2_scope.
    Delimit Scope r2_scope with R2.
    Eval compute in ((Point2 0 1) + (Point2 2 3))%R2.
    
    Inductive le : nat -> nat -> Prop :=
      | le_n : forall n, le n n
      | le_S : forall n m : nat, le n m -> le n (S m).
    
    Fixpoint le (n m : nat) : Prop :=
      match n with
      | 0 => True
      | S n =>
        match m with
        | 0 => False
        | S m => le n m
        end
      end.