idris

I can't prove (n - 0) = n with Idris

≡放荡痞女 提交于 2019-12-03 11:27:20
I am trying to prove, what to my mind is a reasonable theorem: theorem1 : (n : Nat) -> (m : Nat) -> (n + (m - n)) = m Proof by induction gets to the point where me need to prove this: lemma1 : (n : Nat) -> (n - 0) = n This is what happens when I try to prove it (the lemma, for simplicity sake) using the interactive prover: ---------- Goal: ---------- {hole0} : (n : Nat) -> minus n 0 = n > intros ---------- Other goals: ---------- {hole0} ---------- Assumptions: ---------- n : Nat ---------- Goal: ---------- {hole1} : minus n 0 = n > trivial Can't unify n = n with minus n 0 = n Specifically:

Difference between Haskell and Idris: Reflection of Runtime/Compiletime in the type universes

可紊 提交于 2019-12-03 09:06:37
问题 So in Idris it's perfectly valid to write the following. item : (b : Bool) -> if b then Nat else List Nat item True = 42 item False = [1,2,3] // cf. https://www.youtube.com/watch?v=AWeT_G04a0A Without the type signature, this looks like a dynamically typed language. But, indeed, Idris is dependently-typed. The concrete type of item b can only be determined during run-time. This is, of course, a Haskell-programmer talking: The type of item b in the Idris sense is given during compile-time, it

Open Type Level Proofs in Haskell/Idris

人走茶凉 提交于 2019-12-03 08:08:08
问题 In Idris/Haskell, one can prove properties of data by annotating the types and using GADT constructors, such as with Vect, however, this requires hardcoding the property into the type (e.g. a Vect has to be a separate type from a List). Is it possible to have types with an open set of properties (such as list carrying both a length and running average), for example by overloading constructors or using something in the vein of Effect? 回答1: I believe that McBride has answered that question (for

Proof assistant for mathematics only

风格不统一 提交于 2019-12-03 07:40:30
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? Coq has extensive libraries covering real analysis. Various developments come to mind: the standard library and projects building on it such as the now

How can I establish a bijection between a tree and its traversal?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:05:14
I was looking at How does inorder+preorder construct unique binary tree? and thought it would be fun to write a formal proof of it in Idris. Unfortunately, I got stuck fairly early on, trying to prove that the ways to find an element in a tree correspond to the ways to find it in its inorder traversal (of course, I'll also need to do that for the preorder traversal). Any ideas would be welcome. I'm not particularly interested in a complete solution—more just help getting started in the right direction. Given data Tree a = Tip | Node (Tree a) a (Tree a) I can convert it to a list in at least

Dependent types can prove your code is correct up to a specification. But how do you prove the specification is correct?

不打扰是莪最后的温柔 提交于 2019-12-03 05:24:00
问题 Dependent types are often advertised as a way to enable you to assert that a program is correct up to a specification. So, for example, you are asked to write a code that sorts a list - you are able to prove that code is correct by encoding the notion of "sort" as a type, and writing a function such as List a -> SortedList a . But how do you prove that the specification, SortedList , is correct? Wouldn't it be the case that, the more complex your specification is, the more likely it would be

Why haven't newer dependently typed languages adopted SSReflect's approach?

最后都变了- 提交于 2019-12-03 04:14:57
问题 There are two conventions I've found in Coq's SSReflect extension that seem particularly useful but which I haven't seen widely adopted in newer dependently-typed languages (Lean, Agda, Idris). Firstly, where possible predicates are expressed as boolean-returning functions rather than inductively defined datatypes. This brings decidability by default, opens up more opportunities for proof by computation, and improves checking performance by avoiding the need for the proof engine to carry

How do I prove a “seemingly obvious” fact when relevant types are abstracted by a lambda in Idris?

我们两清 提交于 2019-12-03 02:24:39
I am writing a basic monadic parser in Idris, to get used to the syntax and differences from Haskell. I have the basics of that working just fine, but I am stuck on trying to create VerifiedSemigroup and VerifiedMonoid instances for the parser. Without further ado, here's the parser type, Semigroup, and Monoid instances, and the start of a VerifiedSemigroup instance. data ParserM a = Parser (String -> List (a, String)) parse : ParserM a -> String -> List (a, String) parse (Parser p) = p instance Semigroup (ParserM a) where p <+> q = Parser (\s => parse p s ++ parse q s) instance Monoid

Where to start with dependent type programming? [closed]

自作多情 提交于 2019-12-03 02:14:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . There is an Idris tutorial, an Agda tutorial and many other tutorial style papers and introductory material with never ending references to things yet to learn. I'm kind of crawling in the middle of all these and most of the time I'm stuck with mathematical notations and new terminology appearing suddenly with

Converting Coq to Idris

本秂侑毒 提交于 2019-12-02 20:56:24
What would be some useful guidelines for converting Coq source to Idris (e.g. how similar are their type systems and what can be made of translating the proofs)? From what I gather, Idris' built-in library of tactics is minimal yet extendable, so I suppose with some extra work this should be possible. I've recently translated a chunk of Software Foundations and did a partial port of {P|N|Z}Arith , some observations I've made in the process: Generally using Idris tactics (in their Pruvloj / Elab.Reflection form) is not really recommended at the moment, this facility is somewhat fragile, and