Below is an example TPTP file (in TFF‑syntax) that defines Boolean values, the Boolean functions XOR (for the “sum” output) and AND (for the “carry” output), and then specifies a predicate for a half‐adder. In a half‑adder the sum output is defined as the XOR of the two input bits while the carry output is defined as the AND of the inputs. At the end a sample conjecture asserts that the half adder for inputs “true” and “true” produces sum “false” and carry “true”. You can save the following code to a file (say, “half_adder.tptp”) and use your favorite TPTP‐compliant theorem prover to check the conjecture.
%------------------------------------------------------------------
% TPTP File: half_adder.tptp
% Description: A TPTP (TFF) presentation of a half-adder.
%
% A half-adder is a combinational circuit that takes two Boolean
% inputs (A and B) and produces two outputs: Sum and Carry.
% The outputs satisfy:
%
% Sum = XOR(A, B)
% Carry = AND(A, B)
%
% This file defines a predicate half_adder/4 such that:
%
% half_adder(A,B, Sum, Carry) <=> (Sum = xor(A,B)) & (Carry = and(A,B))
%
% Additionally, it asserts (as a conjecture) that:
%
% half_adder(true, true, false, true)
%
% For example, when both inputs are true, the XOR is false and
% the AND is true.
%------------------------------------------------------------------
% Declare a type for Booleans:
tff(bool_type, type, bool: $tType).
% Declare the Boolean constants:
tff(true_decl, type, true: bool).
tff(false_decl, type, false: bool).
% ------------------------------------------------------------
% Define the Boolean function XOR: bool * bool -> bool.
% It is defined by:
%
% xor(true, true) = false
% xor(true, false) = true
% xor(false, true) = true
% xor(false, false) = false
% ------------------------------------------------------------
tff(xor_type, type, xor: bool * bool > bool).
tff(xor_tt, axiom, ( xor(true, true) = false )).
tff(xor_tf, axiom, ( xor(true, false) = true )).
tff(xor_ft, axiom, ( xor(false, true) = true )).
tff(xor_ff, axiom, ( xor(false, false) = false )).
% ------------------------------------------------------------
% Define the Boolean function AND: bool * bool -> bool.
% It is defined by:
%
% and(true, true) = true
% and(true, false) = false
% and(false, true) = false
% and(false, false) = false
% ------------------------------------------------------------
tff(and_type, type, and: bool * bool > bool).
tff(and_tt, axiom, ( and(true, true) = true )).
tff(and_tf, axiom, ( and(true, false) = false )).
tff(and_ft, axiom, ( and(false, true) = false )).
tff(and_ff, axiom, ( and(false, false) = false )).
% ------------------------------------------------------------
% Define the half-adder predicate.
%
% We use a four-argument predicate half_adder/4 with type:
% half_adder: bool * bool * bool * bool -> $o
%
% Its intended meaning is:
% half_adder(A, B, Sum, Carry) <=> (Sum = xor(A, B)) & (Carry = and(A, B))
% ------------------------------------------------------------
tff(half_adder_type, type, half_adder: bool * bool * bool * bool > $o).
tff(half_adder_def, axiom,
![A: bool, B: bool, Sum: bool, Carry: bool]:
( half_adder(A, B, Sum, Carry) <=>
( (Sum = xor(A, B)) & (Carry = and(A, B) ) )
)
).
% ------------------------------------------------------------
% Conjecture (Test): Demonstrate that the half-adder for inputs
% true and true produces sum false and carry true.
% ------------------------------------------------------------
tff(conjecture, conjecture, half_adder(true, true, false, true) ).
How This Works
-
Boolean Type and Constants:
We first declare a type bool along with the two constants true and false.
-
Defining XOR and AND:
The functions xor and and are defined by their standard truth tables using axioms.
-
Defining the Half-Adder:
The predicate half_adder(A,B,Sum,Carry) is defined so that for every pair of Booleans A and B, the outputs Sum and Carry are given by xor(A,B) and and(A,B) respectively.
-
Conjecture:
The conjecture asserts that when both inputs are true, the half-adder produces false for the sum (since XOR(true, true) is false) and true for the carry (since AND(true, true) is true).
You can use a TPTP-compliant theorem prover (like E, Vampire, or others) to check that the conjecture is indeed a logical consequence of the above axioms.
This complete file provides a self-contained presentation of a half-adder in TPTP format.