agda

So: what's the point?

此生再无相见时 提交于 2019-11-27 13:31:51
What is the intended purpose of the So type? Transliterating into Agda: data So : Bool → Set where oh : So true So lifts a Boolean proposition up to a logical one. Oury and Swierstra's introductory paper The Power of Pi gives an example of a relational algebra indexed by the tables' columns. Taking the product of two tables requires that they have different columns, for which they use So : Schema = List (String × U) -- U is the universe of SQL types -- false iff the schemas share any column names disjoint : Schema -> Schema -> Bool disjoint = ... data RA : Schema → Set where -- ... Product : ∀

Parametrized Inductive Types in Agda

泄露秘密 提交于 2019-11-27 12:25:07
问题 I'm just reading Dependent Types at Work. In the introduction to parametrised types, the author mentions that in this declaration data List (A : Set) : Set where [] : List A _::_ : A → List A → List A the type of List is Set → Set and that A becomes implicit argument to both constructors, ie. [] : {A : Set} → List A _::_ : {A : Set} → A → List A → List A Well, I tried to rewrite it a bit differently data List : Set → Set where [] : {A : Set} → List A _::_ : {A : Set} → A → List A → List A

Problems on data type indices that uses list concatenation

不打扰是莪最后的温柔 提交于 2019-11-27 07:32:48
问题 I'm having a nasty problem with a formalisation of a theorem that uses a data type that have some constructors whose indices have list concatenation. When I try to use emacs mode to case split, Agda returns the following error message: I'm not sure if there should be a case for the constructor o-success, because I get stuck when trying to solve the following unification problems (inferred index ≟ expected index): e₁ o e'' , x₁ ++ x'' ++ y₁ ≟ e o e' , x ++ x' ++ y suc (n₂ + n'') , x₁ ++ x'' ≟

Eliminating a Maybe at the type level

眉间皱痕 提交于 2019-11-27 06:24:55
问题 Is there any way to unwrap a value, which is inside the Maybe monad, at the type level? For example, how to define type-safe tail for Vec s having this variant of pred : pred : ℕ -> Maybe ℕ pred 0 = nothing pred (suc n) = just n ? Something like tail : ∀ {n α} {A : Set α} -> Vec A n -> if isJust (pred n) then Vec A (from-just (pred n)) else ⊤ This example is totally artificial, but it's not always possible to get rid of some precondition, so you can write a correct by construction definition

Difference between type parameters and indices?

*爱你&永不变心* 提交于 2019-11-27 03:58:15
I am new to dependent types and am confused about the difference between the two. It seems people usually say a type is parameterized by another type and indexed by some value . But isn't there no distinction between types and terms in a dependently typed language? Is the distinction between parameters and indices fundamental? Can you show me examples showing difference in their meanings in both programming and theorem proving? When you see a family of types, you may wonder whether each of the arguments it has are parameters or indices . Parameters are merely indicative that the type is

Is there a language with constrainable types?

隐身守侯 提交于 2019-11-27 02:33:56
问题 Is there a typed programming language where I can constrain types like the following two examples? A Probability is a floating point number with minimum value 0.0 and maximum value 1.0. type Probability subtype of float where max_value = 0.0 min_value = 1.0 A Discrete Probability Distribution is a map, where: the keys should all be the same type, the values are all Probabilities, and the sum of the values = 1.0. type DPD<K> subtype of map<K, Probability> where sum(values) = 1.0 As far as I

Why is typecase a bad thing? [closed]

早过忘川 提交于 2019-11-26 22:41:15
问题 Both Agda and Idris effectively prohibit pattern matching on values of type Type . It seems that Agda always matches on the first case, while Idris just throws an error. So, why is typecase a bad thing? Does it break consistency? I haven't been able to find much information regarding the topic. 回答1: It's really odd that people think pattern matching on types is bad. We get a lot of mileage out of pattern matching on data which encode types, whenever we do a universe construction. If you take

So: what's the point?

别等时光非礼了梦想. 提交于 2019-11-26 18:15:18
问题 What is the intended purpose of the So type? Transliterating into Agda: data So : Bool → Set where oh : So true So lifts a Boolean proposition up to a logical one. Oury and Swierstra's introductory paper The Power of Pi gives an example of a relational algebra indexed by the tables' columns. Taking the product of two tables requires that they have different columns, for which they use So : Schema = List (String × U) -- U is the universe of SQL types -- false iff the schemas share any column

Types containing with/rewrite clauses in agda, or, how to use rewrite instead of subst?

时间秒杀一切 提交于 2019-11-26 16:53:09
问题 First some boring imports: import Relation.Binary.PropositionalEquality as PE import Relation.Binary.HeterogeneousEquality as HE import Algebra import Data.Nat import Data.Nat.Properties open PE open HE using (_≅_) open CommutativeSemiring commutativeSemiring using (+-commutativeMonoid) open CommutativeMonoid +-commutativeMonoid using () renaming (comm to +-comm) Now suppose that I have a type indexed by, say, the naturals. postulate Foo : ℕ -> Set And that I want to prove some equalities