curry-howard

De Morgan's Laws in Haskell via the Curry-Howard Correspondence

此生再无相见时 提交于 2020-01-01 19:15:54
问题 I implemented three of the four De Morgan's Laws in Haskell: notAandNotB :: (a -> c, b -> c) -> Either a b -> c notAandNotB (f, g) (Left x) = f x notAandNotB (f, g) (Right y) = g y notAorB :: (Either a b -> c) -> (a -> c, b -> c) notAorB f = (f . Left, f . Right) notAorNotB :: Either (a -> c) (b -> c) -> (a, b) -> c notAorNotB (Left f) (x, y) = f x notAorNotB (Right g) (x, y) = g y However, I don't suppose that it's possible to implement the last law (which has two inhabitants): notAandBLeft

How or is that possible to prove or falsify `forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q.` in Coq?

眉间皱痕 提交于 2019-12-28 18:04:06
问题 I want to prove or falsify forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q. in Coq. Here is my approach. Inductive True2 : Prop := | One : True2 | Two : True2. Lemma True_has_one : forall (t0 t1 : True), t0 = t1. Proof. intros. destruct t0. destruct t1. reflexivity. Qed. Lemma not_True2_has_one : (forall (t0 t1 : True2), t0 = t1) -> False. Proof. intros. specialize (H One Two). inversion H. But, inversion H does nothing. I think maybe it's because the coq's proof independence (I'm not a

Curry's paradox in Haskell?

放肆的年华 提交于 2019-12-22 06:59:37
问题 Curry's paradox (named after the same person as the present programming language) is a construction possible in a faulty logic that allows one to prove anything. I know nothing about logic, but how hard can it be? module Main where import Data.Void import Data.Function data X = X (X -> Void) x :: X x = fix \(X f) -> X f u :: Void u = let (X f) = x in f x main :: IO () main = u `seq` print "Done!" It certainly does loop. (How does GHC know?!) % ghc -XBlockArguments Z.hs && ./Z [1 of 1]

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

De Morgan's Laws in Haskell via the Curry-Howard Correspondence

此生再无相见时 提交于 2019-12-04 18:06:50
I implemented three of the four De Morgan's Laws in Haskell: notAandNotB :: (a -> c, b -> c) -> Either a b -> c notAandNotB (f, g) (Left x) = f x notAandNotB (f, g) (Right y) = g y notAorB :: (Either a b -> c) -> (a -> c, b -> c) notAorB f = (f . Left, f . Right) notAorNotB :: Either (a -> c) (b -> c) -> (a, b) -> c notAorNotB (Left f) (x, y) = f x notAorNotB (Right g) (x, y) = g y However, I don't suppose that it's possible to implement the last law (which has two inhabitants): notAandBLeft :: ((a, b) -> c) -> Either (a -> c) (b -> c) notAandBLeft f = Left (\a -> f (a, ?)) notAandBRight :: (

What are the most interesting equivalences arising from the Curry-Howard Isomorphism?

China☆狼群 提交于 2019-12-04 07:41:11
问题 I came upon the Curry-Howard Isomorphism relatively late in my programming life, and perhaps this contributes to my being utterly fascinated by it. It implies that for every programming concept there exists a precise analogue in formal logic, and vice versa. Here's a "basic" list of such analogies, off the top of my head: program/definition | proof type/declaration | proposition inhabited type | theorem/lemma function | implication function argument | hypothesis/antecedent function result |

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

天大地大妈咪最大 提交于 2019-12-02 15:07:40
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 represented as a pair whose first element is a particular value x of type A and whose second element is a

What are the most interesting equivalences arising from the Curry-Howard Isomorphism?

旧街凉风 提交于 2019-12-02 13:47:35
I came upon the Curry-Howard Isomorphism relatively late in my programming life, and perhaps this contributes to my being utterly fascinated by it. It implies that for every programming concept there exists a precise analogue in formal logic, and vice versa. Here's a "basic" list of such analogies, off the top of my head: program/definition | proof type/declaration | proposition inhabited type | theorem/lemma function | implication function argument | hypothesis/antecedent function result | conclusion/consequent function application | modus ponens recursion | induction identity function |