agda

Defining non-unary functions in Cubical mode

折月煮酒 提交于 2019-12-21 04:58:31
问题 I'd like to define a function with two, higher inductive typed, arguments in Cubical mode. I am using the cubical package as my "prelude" library. I first define a quotient type for integers as a HIT: {-# OPTIONS --cubical #-} module _ where open import Data.Nat renaming (_+_ to _+̂_) open import Cubical.Core.Prelude data ℤ : Set where _-_ : (x : ℕ) → (y : ℕ) → ℤ quot : ∀ {x y x′ y′} → (x ℕ+ y′) ≡ (x′ ℕ+ y) → (x - y) ≡ (x′ - y′) I can then define a unary function using pattern matching: _+1 :

Haskell Deriving Mechanism for Agda

安稳与你 提交于 2019-12-21 04:49:20
问题 I am wondering if there is anything in Agda that resembles Haskell's deriving Eq clause ---then I have an associated question below, as well. For example, suppose I have types for a toy-language, data Type : Set where Nat : Type Prp : Type Then I can implement decidable equality by pattern matching and C-c C-a , _≟ₜ_ : Decidable {A = Type} _≡_ Nat ≟ₜ Nat = yes refl Nat ≟ₜ Prp = no (λ ()) Prp ≟ₜ Nat = no (λ ()) Prp ≟ₜ Prp = yes refl I'm curious if this can be mechanised or automated somehow

What are cumulative universes and `* : *`?

坚强是说给别人听的谎言 提交于 2019-12-21 04:46:27
问题 In Agda, there is Set n . As I understand, Set n extends the Haskell-style value-type-kind hierarchy to infinite levels. That is, Set 0 is the universe of normal types, Set 1 is the universe of normal kinds, Set 2 is the universe of normal sorts, etc. In contrast, Idris has the so called "cumulative hierarchy of universes". It seems that for a < b , Type a: Type b , and universe levels are inferred. But what does it mean in real world programs? Can't we define something that only operate on

Proof assistant for mathematics only

旧巷老猫 提交于 2019-12-21 01:18:29
问题 Most proof assistants are functional programming languages with dependent types. They can proof programs/algorithms. I'm interested, instead, in proof assistant suitable best for mathematics and only (calculus for instance). Can you recommend one? I heard about Mizar but I don’t like that the source code is closed, but if it is best for math I will use it. How well the new languages such as Agda and Idris are suited for mathematical proofs? 回答1: Coq has extensive libraries covering real

Why do we need containers?

拜拜、爱过 提交于 2019-12-20 09:23:15
问题 (As an excuse: the title mimics the title of Why do we need monads?) There are containers (and indexed ones) (and hasochistic ones) and descriptions. But containers are problematic and to my very small experience it's harder to think in terms of containers than in terms of descriptions. The type of non-indexed containers is isomorphic to Σ — that's quite too unspecific. The shapes-and-positions description helps, but in ⟦_⟧ᶜ : ∀ {α β γ} -> Container α β -> Set γ -> Set (α ⊔ β ⊔ γ) ⟦ Sh ◃ Pos

Dependent Types: How is the dependent pair type analogous to a disjoint union?

隐身守侯 提交于 2019-12-20 08:39:46
问题 I've been studying dependent types and I understand the following: Why universal quantification is represented as a dependent function type. ∀(x:A).B(x) means “for all x of type A there is a value of type B(x) ” . Hence it's represented as a function which when given any value x of type A returns a value of type B(x) . Why existential quantification is represented as a dependent pair type. ∃(x:A).B(x) means “there exists an x of type A for which there is a value of type B(x) ” . Hence it's

How to learn agda

不想你离开。 提交于 2019-12-20 08:02:02
问题 I am trying to learn agda. However, I got a problem. All the tutorials which I found on agda wiki are too complex for me and cover different aspects of programming. After parallel reading of 3 tutorials on agda I was able to write simple proofs but I still don't have enough knowledge to use it for real word algorithm correctness. Can you recommend me any tutorials on the subject? Something similar to Learn Yourself a Haskell but for Agda. 回答1: When I started learning Agda about a year ago I

How to resolve this error in agda?

你说的曾经没有我的故事 提交于 2019-12-20 05:37:09
问题 I have defined Stream of positive rational like this. one : ℤ one = + 1 --giving a rational as input it will return next rational (in some down tailing method) next : pair → pair next q = if (n eq one) then (mkPair (+ m Data.Integer.+ one) 1) else (mkPair (n Data.Integer.- one) (m Nat.+ 1)) where n = getX q m = getY q --it will generate all rational from (1,1) rational : Stream pair rational = iterate next (mkPair one 1) --it will get all the rational which are greater than the given rational

How to define division operator in Agda?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 06:59:47
问题 I want to divide two natural number. I have made function like this _/_ : N -> N -> frac m / one = m / one (suc m) / n = ?? I dont know what to write here. Please help. 回答1: As @gallais says you can use well-founded recursion explicitly, but I don't like this approach, because it's totally unreadable. This datatype record Is {α} {A : Set α} (x : A) : Set α where ¡ = x open Is ! : ∀ {α} {A : Set α} -> (x : A) -> Is x ! _ = _ allows to lift values to the type level, for example you can define a

Assisting Agda's termination checker

余生颓废 提交于 2019-12-17 15:55:19
问题 Suppose we define a function f : N \to N f 0 = 0 f (s n) = f (n/2) -- this / operator is implemented as floored division. Agda will paint f in salmon because it cannot tell if n/2 is smaller than n. I don't know how to tell Agda's termination checker anything. I see in the standard library they have a floored division by 2 and a proof that n/2 < n. However, I still fail to see how to get the termination checker to realize that recursion has been made on a smaller subproblem. 回答1: Agda's