agda

Pattern matching in Observational Type Theory

江枫思渺然 提交于 2019-12-03 10:35:00
In the end of the "5. Full OTT" section of Towards Observational Type Theory the authors show how to define coercible-under-constructors indexed data types in OTT. The idea is basically to turn indexed data types into parameterized like this: data IFin : ℕ -> Set where zero : ∀ {n} -> IFin (suc n) suc : ∀ {n} -> IFin n -> IFin (suc n) data PFin (m : ℕ) : Set where zero : ∀ {n} -> suc n ≡ m -> PFin m suc : ∀ {n} -> suc n ≡ m -> PFin n -> PFin m Conor also mentions this technique at the bottom of observational type theory (delivery) : The fix, of course, is to do what the GADT people did, and

Agda: how does one obtain a value of a dependent type?

让人想犯罪 __ 提交于 2019-12-03 08:19:13
I recently asked this question: An agda proposition used in the type -- what does it mean? and received a very well thought out answer on how to make types implicit and get a real compile time error. However, it is still unclear to me, how to create a value with a dependent type. Consider: div : (n : N) -> even n -> N div zero p = zero div (succ (succ n)) p= succ (div n p) div (succ zero) () Where N is the natural numbers and even is the following proposition. even : N -> Set even zero = \top even (succ zero) = \bot even (succ (succ n)) = even n data \bot : Set where record \top : Set where

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

Modeling the ST monad in Agda

て烟熏妆下的殇ゞ 提交于 2019-12-03 06:06:58
This recent SO question prompted me to write an unsafe and pure emulation of the ST monad in Haskell, a slightly modified version of which you can see below: {-# LANGUAGE DeriveFunctor, GeneralizedNewtypeDeriving, RankNTypes #-} import Control.Monad.Trans.State import GHC.Prim (Any) import Unsafe.Coerce (unsafeCoerce) import Data.List newtype ST s a = ST (State ([Any], Int) a) deriving (Functor, Applicative, Monad) newtype STRef s a = STRef Int deriving Show newSTRef :: a -> ST s (STRef s a) newSTRef a = ST $ do (env, i) <- get put (unsafeCoerce a : env, i + 1) pure (STRef i) update :: [a] ->

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

What is the combinatory logic equivalent of intuitionistic type theory?

我与影子孤独终老i 提交于 2019-12-03 00:11:27
问题 I recently completed a university course which featured Haskell and Agda (a dependent typed functional programming language), and was wondering if it was possible to replace lambda calculus in these with combinatory logic. With Haskell this seems possible using the S and K combinators, thus making it point-free. I was wondering what the equivalent was for Agda. I.e., can one make a dependently typed functional programming language equivalent to Agda without using any variables? Also, is it