typeLmNat a b c = a -> b -> c c0 = \s -> \z -> z -- Note that c0 is equivalent to that of `False` c1 = \s -> \z -> s z c2 = \s -> \z -> s $ s z
scc = \n -> \s -> \z -> s (n s z)
-- Somewhat clumsy definition scc' = \n -> \s -> \z -> c1 s (n s z)
-- The alternative definition could be easily spotted underneath -- in that of `prd` plus = \x -> \y -> \s -> \z -> x s (y s z)
times = \x -> \y -> x (plus y) c0
pow = \x -> \y -> y (times x) c1
-- Natural number wrappings data Nat = Zero | Succ Nat deriving Show
-- eval natural number as_num :: LmNat (Nat -> Nat) Nat Nat -> Nat as_num = \n -> n Succ Zero
-- Previous logic system tru = \t -> \f -> t fls = \t -> \f -> f as_bool = \u -> u True False
iszero = \n -> n ss zz where zz = tru ss = \_ -> fls
-- Previous pair system typePair a b c = a -> b -> (a -> b -> c) -> c pair :: Pair a b c pair = \f -> \s -> \b -> b f s fst' = \p -> p tru snd' = \p -> p fls
-- This wouldn't work in haskell ~ because this laji could not infer infinite type prd = \x -> fst' (x zz ss) where zz = pair c0 c0 ss = \p -> pair (snd' p) (plus c1 $ fst' p) -- Approximately (n + 1) steps of big-stepped evaluation is required to compute `prd`
-- So this would not work sub = \x -> \y -> \s -> \z -> y prd (x s z)
-- So do this equal = \x -> \y -> iszero $ sub x y