CSE 230: Principles of Programming Languages
Propositional Logic in OBJ3

Below are the OBJ3 source code and output log for a version of the Post system for propositional logic given by Stansifer in Section 2.4.4. The expression to be reduced corresponds to his proof on page 67. Notice that the OBJ style is a bit different from that of the Post system, because it uses abstract data types for the atomic predicates and formulae, defines the productions using rewrite rules, defines proofs by terms, and uses term rewriting to extract the result of a proof (proofs are also represented as terms in type theory). Here is the code:

  obj PROP is
    sorts P F Th .
    op P  :  -> P .
    op _| : P -> P .
    subsorts P < F .
    op N_ : F -> F [prec 2].
    op C__ : F F -> F [prec 15].
    op Th_ : F -> Th [prec 5].
    op a1 : F -> Th .
    op a2 : F F -> Th .
    op a3 : F F F -> Th .
    op mp : Th Th -> Th .
    vars X Y Z : F .
    eq a1(X) =     Th( C (C N X X) X ).
    eq a2(X,Y) =   Th( C X (C (N X) Y) ).
    eq a3(X,Y,Z) = Th( C (C X Y) (C (C Y Z) (C X Z)) ).
    eq mp(Th(C X Y), Th X) = Th Y .

  red mp(a3(C (N P) P, P, P |), a1(P)).
And here is its output:
  awk% obj
                     --- Welcome to OBJ3 ---
           OBJ3 version 2.04oxford built: 1994 Feb 28 Mon 15:07:40
              Copyright 1988,1989,1991 SRI International
                     2001 Jan 30 Tue 19:23:27
  OBJ> in post
  obj PROP
  reduce in PROP : mp(a3(C N P P,P,P |),a1(P))
  rewrites: 3
  result Th: Th (C (C P (P |)) (C (C N P P) (P |)))
  OBJ> q
Here mp(a3(C N P P,P,P |),a1(P)) is the proof term, while Th (C (C P (P |)) (C (C N P P) (P |))) is the result of the proof. (All this was done in the emacs editor, including use of its html mode, which produces the timestamp.)

To CSE 230 homepage
Maintained by Joseph Goguen
Last modified: Wed Jan 31 10:17:43 PST 2001