Last active
August 26, 2015 11:14
-
-
Save zah/ccfaf21e56ba25c64bfd to your computer and use it in GitHub Desktop.
Proof-carrying Nim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hello world program | |
type | |
Implies[A, B] = proc(a: A): B | |
# example Propositions | |
type | |
X = object | |
Y = object | |
Z = object | |
proc transitive_implication(hypothesis_XY: Implies[X, Y], | |
hypothesis_YZ: Implies[Y, Z]): Implies[X, Z] = | |
# if you are able to construct a value of the result type from the input types | |
# you are proving that the result proposions follows from the hypotheses | |
result = | |
proc(x: X): Z = | |
let y = hypothesis_XY(x) | |
let z = hypothesis_YZ(y) | |
return z | |
# one problem is that in Nim it's possible cheat and produce the final type | |
# without real construction: | |
let problem = | |
proc(x: X): Z = | |
discard | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment