1
votes

I'm new to Agda. I have the following code that I want to prove. Right now I have problem wit lemma1c. since it wants me to prove when z = a, z will equal to c. and I have a = c and c = c, and the trans function. So I was trying to write

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

but I want getting the z is not in scope error. 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}

2

2 Answers

2
votes

You have to call the trans function with explicit parameters (without the brackets) which leads to the following definition:

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:

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

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. 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} = ....