简体   繁体   English

关于 Agda 中的平等

[英]About equality in Agda

I'm new to Agda.我是 Agda 的新手。 I have the following code that I want to prove.我有以下代码要证明。 Right now I have problem wit lemma1c.现在我有 lemma1c 的问题。 since it wants me to prove when z = a, z will equal to c.因为它要我证明当 z = a 时,z 将等于 c。 and I have a = c and c = c, and the trans function.我有 a = c 和 c = c,以及 trans 函数。 So I was trying to write所以我试着写

lemma1c = trans {z = a}, {a = c}

but I want getting the z is not in scope error.但我想得到 z is not in scope 错误。 How can I solve this?我该如何解决这个问题?

postulate
  A : Set
  a : A
  b : A
  c : A
  p : a ≡ b
  q : b ≡ c
  trans : ∀ {ℓ}{A : Set ℓ}{x y z : A} → x ≡ y → y ≡ z → x ≡ z
  trans refl refl = refl

  lemma0 : c ≡ c
  lemma0 = refl
  -- Goal: c ≡ c, refl: x ≡ x
  lemma1a : a ≡ c
  lemma1a rewrite p = q

  lemma1c : ∀ {z : A} → z ≡ a → z ≡ c
  lemma1c {z} = trans {} {lemma1a}

You have to call the trans function with explicit parameters (without the brackets) which leads to the following definition:您必须使用显式参数(不带括号)调用trans函数,这会导致以下定义:

lemma1c : ∀ {z : A} → z ≡ a → z ≡ c
lemma1c z≡a = trans z≡a lemma1a

You could also use rewrite as you did in the previous lemma:您还可以像在前面的引理中一样使用rewrite

lemma1d : ∀ {z : A} → z ≡ a → z ≡ c
lemma1d z≡a rewrite lemma1a = z≡a

Curly braces are used to mark up implicit arguments.花括号用于标记隐式参数。 That is, arguments that usually Agda can work out from the context - like, by passing a dependently typed x ≡ y to trans you already tell Agda what , A , x and y are.也就是说,通常 Agda 可以从上下文中计算出的参数 - 例如,通过将依赖类型的x ≡ y传递给trans您已经告诉 Agda Axy是什么。 Similarly by marking {z} as an implicit argument, you don't need to pass it to lemma1c explicitly, and often do not need to match it on the line lemma1c {z} = ... .同样,通过将{z}标记为隐式参数,您不需要将其显式传递给lemma1c ,并且通常不需要在lemma1c {z} = ...行匹配它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM