idris

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

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 can I express range validity in Idris?

百般思念 提交于 2019-12-20 03:21:40
问题 I am trying to model a simple survey form in Idris and currently struggling with validating user input, which comes as a string, w.r.t. to the type of questions asked. Currently I have the following types: data Question : Type where QCM : {numOptions : Nat} -> (question : String) -> (qcmOptions : Vect numOptions String) -> (expected : Fin numOptions) -> Question data Answer : (q : Question) -> Type where AnswerQCM : (option : Fin n) -> Answer (QCM {numOptions = n } q opts exp) total

Difference between type parameters and indices?

感情迁移 提交于 2019-12-17 06:37:19
问题 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? 回答1: When you see a family of types, you may wonder whether each

How can I describe this property of divisibility in Idris?

家住魔仙堡 提交于 2019-12-13 18:01:10
问题 I want to prove that if b (Integer) divides a (Integer), then b also divides a * c (where c is an Integer). First, I need to reformulate the problem into a computer understandable problem, here was an attempt: -- If a is divisible by b, then there exists an integer such that a = b * n divisibleBy : (a, b : Integer) -> (n : Integer ** (a = b * n)) -- If b | a then b | ac. alsoDividesMultiples : (a, b, c : Integer) -> (divisibleBy a b) -> (divisibleBy (a * c) b) However, I am getting

How to Compare Types for Equality?

流过昼夜 提交于 2019-12-13 12:07:03
问题 I attempted to compare a String and String , expecting True . Idris> String == String Can't find implementation for Eq Type Then I expected False when comparing a String to a Bool . Idris> String /= Bool Can't find implementation for Eq Type Am I missing an import ? 回答1: You can't as it would break parametricity, which we have in Idris. We can't pattern match on types. But this would be necessary to write the Eq implementation, for example: {- Doesn't work! eqNat : Type -> Bool eqNat Nat =

Simple dependently typed Temperature converter in Haskell, is it possible to make this code shorter?

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:22:32
问题 The function convert below has the type signature : SUnit fromUnit-> SUnit toUnit ->Value fromUnit -> Value toUnit , which has redundancy , because the same information could be expressed by : Value fromUnit -> Value toUnit . 1) Is there a way to get rid of the first two arguments ( SUnit fromUnit-> SUnit toUnit ) ? 2) Is there some other way by which this simple dependently typed program could be written more elegantly ? 3) How would this program look like in Idris ? {-# LANGUAGE GADTs

Why does this 'with' block spoil the totality of this function?

大兔子大兔子 提交于 2019-12-12 17:50:38
问题 I'm trying to compute parity together with the floor of the half, over natural numbers: data IsEven : Nat -> Nat -> Type where Times2 : (n : Nat) -> IsEven (n + n) n data IsOdd : Nat -> Nat -> Type where Times2Plus1 : (n : Nat) -> IsOdd (S (n + n)) n parity : (n : Nat) -> Either (Exists (IsEven n)) (Exists (IsOdd n)) I tried going with the obvious implementation of parity : parity Z = Left $ Evidence _ $ Times2 0 parity (S Z) = Right $ Evidence _ $ Times2Plus1 0 parity (S (S n)) with (parity

Impossible patterns in Idris

橙三吉。 提交于 2019-12-12 11:34:51
问题 I'm learning Idris and I got stuck on a very simple lemma that shows that some specific index is impossible for a data type. I've tried to use impossible patterns but Idris refuses them with the following error message: RegExp.idr line 32 col 13: hasEmptyZero prf is a valid case The complete code piece is available in the following gist: https://gist.github.com/rodrigogribeiro/f27f1f035e5a98f506ee Any help is appreciated. 回答1: I've talk with people at freenode Idris community and they