Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define an alias in Agda's type delaration?

My code:

law : ∀ a x → ((suc a) * (suc a) ÷ (suc a) ⟨ x ⟩) →ℕ ≡ (suc a , refl)
law a x = refl

I think there's too many suc a and I want to give an alias to suc a, something like (this code just describes my idea, it doesn't compile):

law : ∀ a x → ((s : suc a) * s ÷ s ⟨ x ⟩) →ℕ ≡ (s , refl)
law a x = refl

Can I achieve that?

like image 276
ice1000 Avatar asked Oct 23 '25 19:10

ice1000


1 Answers

Sure. You can use let

law : ∀ a x → let s = suc a in (s * s ÷ s ⟨ x ⟩) →ℕ ≡ (s , refl)
law a x = refl

or define an anonymous module:

module _ (a : ℕ) where
  s = suc a
  law : ∀ x → (s * s ÷ s ⟨ x ⟩) →ℕ ≡ (s , refl)
  law x = refl

Outside of the module law has the same type signature as the one you provided.

like image 158
user3237465 Avatar answered Oct 26 '25 15:10

user3237465



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!