| Some example code for Pure2 in System F | Copyright 2008, K.D.P.Ross | | This program is free software; you can redistribute it and/or | modify it under the terms of the GNU General Public License as | published by the Free Software Foundation; either version 2 of the | License, or (at your option) any later version. | | This program is distributed in the hope that it will be useful, but | WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | General Public License for more details. | | You should have received a copy of the GNU General Public License | along with this program; if not, write to the Free Software | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | USA CHECKS | Define our PTS -- System F (polymorphic lambda calculus) sort Set Type. axiom Set : Type. rule Set -> Set. rule Type -> Set. | Some polymorphic functions -- standard polymorphic identity function id = \ (a : Set)(prfA : a) -> prfA. id : (a : Set) a -> a. -- function composition compose = \ (a b c : Set)(f : b -> c)(g : a -> b)(x : a) -> f (g x). compose : (a b c : Set)(b -> c) -> (a -> b) -> a -> c. | Some base datatypes -- standard Peano `Nat`s assume Nat : Set. assume Zro : Nat. assume Suc : Nat -> Nat. -- posit an addition function assume Add : Nat -> Nat -> Nat. | Put it all together -- compose some functions composeNatTest = compose Nat Nat Nat (id Nat) (Add (Suc Zro)). composeNatTest : Nat -> Nat.