Coq中带空格和大括号的集合论表示法

Coq中带空格和大括号的集合论表示法,coq,Coq,我想要像“x”这样的标准符号∈ Coq中的{x}”。 但也存在一些问题: 1) 花括号在Coq中有特殊含义,因此发生以下情况: Notation " x ∈ y " :=(tin x y) (at level 50). Notation " { x } ":=(Sing x). Check fun x => (x ∈ { x }). (*error: Unknown interpretation for notation "_ ∈ { _ }". *) 如何正确定义这个符号 2) 如果第

我想要像“x”这样的标准符号∈ Coq中的{x}”。 但也存在一些问题:

1) 花括号在Coq中有特殊含义,因此发生以下情况:

Notation " x ∈ y " :=(tin x y) (at level 50).
Notation " { x } ":=(Sing x).
Check fun x => (x ∈ { x }).
(*error: Unknown interpretation for notation "_ ∈ { _ }". *)
如何正确定义这个符号

2) 如果第一个问题不能解决,还有另一个问题。(在这里,我决定在符号中使用额外的符号“`”。)

现在我应该

a) 在第一个大括号后添加空格或

b) 删除最后一个x字母后的非故意空白


如何执行这些操作?

除了其他符号外,您还可以通过添加
tin x(Sing y)
的符号来使用您的符号。由于几个重叠的符号,解析器中的花括号有些奇怪;有关讨论,请参阅

您可以通过使用Coq的
格式
标记修饰符(请参阅)。或者,在符号中使用两个空格将迫使Coq在那里打印一个空格(在第二个示例中,似乎有时会决定打印一个空格,在这种情况下,您必须采用自定义格式)

以下是针对您的示例实施的所有上述解决方案:

Axiom Ens : Set.
Axiom tin : Ens -> Ens -> Prop.
Axiom Sing : Ens -> Ens.

Section FixingBraceNotation.
  Notation "x  ∈  y" := (tin x y) (at level 50).
  (* Note: the level on the following modifier is already set for this
  notation and so is redundant, but it needs to be reproduced exactly if
  you add a format modifier (you can overwrite the notation but not the
  parsing levels). *)
  Notation "{ x }" := (Sing x) (at level 0, x at level 99).
  Notation "x  ∈  { y }" := (tin x (Sing y)) (at level 50).
  Check fun x => (x ∈ { x }).
  Check fun x => {x}.
End FixingBraceNotation.

Section RemovingWhitespace.
  Notation "x  ∈  y" := (tin x y) (at level 50).
  Notation "{ x }`" := (Sing x) (at level 0, format "{ x }`").
  Check fun x => (x ∈ { x }`).
End RemovingWhitespace.

Section AddingWhitespace.
  Notation "x  ∈  y" := (tin x y) (at level 50).
  Notation "{  x  }`" := (Sing x) (at level 0).
  Check fun x => (x ∈ {x}`).
End AddingWhitespace.

通过添加
tin
Sing
的定义,您能否将此作为一个简单的工作示例?(例如,将它们添加为公理。)谢谢!读了你的答案后,我更容易找到你。同样奇怪的是,嵌套符号是不允许的。我可以问一个相关的问题吗?我试着得到类似的东西,但没有成功
Axiom Ens : Set.
Axiom tin : Ens -> Ens -> Prop.
Axiom Sing : Ens -> Ens.

Section FixingBraceNotation.
  Notation "x  ∈  y" := (tin x y) (at level 50).
  (* Note: the level on the following modifier is already set for this
  notation and so is redundant, but it needs to be reproduced exactly if
  you add a format modifier (you can overwrite the notation but not the
  parsing levels). *)
  Notation "{ x }" := (Sing x) (at level 0, x at level 99).
  Notation "x  ∈  { y }" := (tin x (Sing y)) (at level 50).
  Check fun x => (x ∈ { x }).
  Check fun x => {x}.
End FixingBraceNotation.

Section RemovingWhitespace.
  Notation "x  ∈  y" := (tin x y) (at level 50).
  Notation "{ x }`" := (Sing x) (at level 0, format "{ x }`").
  Check fun x => (x ∈ { x }`).
End RemovingWhitespace.

Section AddingWhitespace.
  Notation "x  ∈  y" := (tin x y) (at level 50).
  Notation "{  x  }`" := (Sing x) (at level 0).
  Check fun x => (x ∈ {x}`).
End AddingWhitespace.