Skip to content

Instantly share code, notes, and snippets.

@zah
Last active August 26, 2015 11:14
Show Gist options
  • Save zah/ccfaf21e56ba25c64bfd to your computer and use it in GitHub Desktop.
Save zah/ccfaf21e56ba25c64bfd to your computer and use it in GitHub Desktop.
Proof-carrying Nim
# 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