Skip to content

Commit

Permalink
Substantial cleanup in the prove function.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqui committed Feb 19, 2009
1 parent 7a32205 commit ae2a178
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions experiments/icl.hs
Expand Up @@ -90,14 +90,17 @@ withNeutral rng f = do

prove :: Term -> Proof ()
prove (L :% L) = return () -- inconsistent impredicativity axiom
prove (f :% n) | Just typeof <- neutral n = unify f =<< typeof
prove (G :% x :% y :% Lam z) = do
prove (L :% (G :% x :% y))
withNeutral x $ \n -> prove . rwhnf $ y :% n :% subst 0 n z
prove (L :% (G :% x :% n)) | Just typeof <- neutral n = do
prove (L :% x)
unify (G :% x :% Lam L) =<< typeof
prove (L :% (G :% x :% Lam t)) = do
prove (f :% x) = do
prove (L :% f)
proveWF f x

-- proveWF f x proves the application f x, under the
-- assumption that L f has already been proven.
proveWF f n | Just typeof <- neutral n =
unify f =<< typeof
proveWF (G :% x :% y) (Lam z) = withNeutral x $ \n ->
prove . rwhnf $ y :% n :% subst 0 n z
proveWF L (G :% x :% y) = do
prove (L :% x)
withNeutral x $ \n -> prove $ L :% subst 0 n t
prove t = fail $ "Couldn't prove " ++ show t ++ ": no applicable rule"
proveWF (G :% x :% Lam L) y
proveWF t u = fail $ "Couldn't prove " ++ show (t :% u)

0 comments on commit ae2a178

Please sign in to comment.