SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Algorithm 1: (continued from previous page)
else if  $r =$  disjunction_introduction   
if  $C = \Omega$  let  $C$  be the set of disjunctions of length 3  $i =$  sample.uniform( number of disjuncts in  $C$  1 do let  $C_i = i^{th}$  operand of  $C$  a  $=$  generate_compositional-proof( $C_i$ ,{disjunction eliminatio},d-1,e,h) while a is atomic and a is not any other operand of  $C$  replace  $i^{th}$  operand of  $C$  with a do  $\begin{array}{rl} & x = \mathrm{sample}(C,e)\\ & \mathrm{while~}i^{th}\mathrm{disjunct~of~}x\mathrm{~is~distinct~from~all~other~disjuncts}\\ & \mathrm{return~disjunction\_introduction~with~premise~given~by~the~}i^{th}\mathrm{~operand~of~}x\mathrm{~and~conclusion~}x \end{array}$  else if  $r =$  disjunction eliminatio initialize  $P$  as an empty list while  $|P| <   2$  do  $p =$  generate_compositional-proof(C,{disjunction_introduction},d-1,e, true) if  $p$  is not a conjunction or disjunction and  $p$  has an axiom that is not an axiom of any  $q\in P$ $\sqsubseteq$  append  $p$  to  $P$  let  $A_{i}$  be the set of axioms of  $P_{i}$  that are not axioms of  $P_{j}$  for  $i\neq j$  let  $a_i =$  sample.uniform  $(A_{i})$  for all i let  $a^\prime$  be a disjunction with disjuncts  $a_i$ $a =$  generate_compositional-proof( $\{a^{\prime}\}$ ,{disjunction_introduction},d-1,e,h) return disjunction_introduction with premises a and  $P_{i}$  else if  $r =$  proof_bycontraiction let  $N$  be the set of all negated logical forms  $a =$  generate_compositional-proof(N,{proof_bycontrastriction},d-1,h) do let  $a = \neg s$  b  $=$  generate_compositional-proof( $\{s\}$ ,{proof_bycontrastriction},d-1,e, true) while b has an atomic non-negated axiom that is not an axiom of a  $s^{\prime} =$  sample.uniform({atomic non-negated axioms of b that are not axioms of a}) return proof_bycontrastriction with premises a and b and conclusion  $\neg s^{\prime}$
A.5 Generating compositional proofs
We use a simple recursive procedure to generate compositional proofs: (1) select a deduction rule uniformly at random, (2) select the premises for the selected rule, (3) recursively generate a subproof for each premise. A consistency checking step is required to make sure we avoid generating contradictory axioms.<sup>6</sup> In addition, we avoid generating an elimination rule directly following an introduction rule (or vice versa).<sup>7</sup> See Algorithm 1 in the appendix for pseudocode of this procedure. To test compositional proofs of various sizes, we implement a parameter that controls the minimum depth of the proof tree, and another parameter that controls the number of distinct rule types in each proof.
A.6 Further details on evaluation of CoT
We aim to test whether LLMs are able to use deduction rules OOD, where the rules do not appear in the in-context examples, and we take care not to be overly strict. For example, we wish to avoid penalizing the model for formatting differences, so long as the reasoning is correct. To this end, in determining whether a logical form follows from previous logical forms, we consider any deduction rule listed in Table 2. We also allow for two additional rules: (1) given  $\forall x(f(x)\to g(x))$  and
44   
45   
46   
47   
48   
49   
50   
51   
52   
53   
54   
55   
56   
57   
58   
59   
60   
61   
62   
63   
64   
65   
66   
67   
68   
69   
70   
71   
72   
73   
74   
75
An example is: Suppose we select conjunction introduction as the first rule; next, we recursively generate the proof of each conjunct; suppose for each of these, we choose to generate the axioms cat(alex) and  $\neg$  cat(alex).
In the following example, a conjunction introduction step immediately follows a conjunction elimination step: "Jay is a cat and orange. Jay is a cat. Jay is orange. Jay is a cat and orange."
$\forall x(g(x)\to h(x))$  conclude  $\forall x(f(x)\to h(x))$ , and (2) given  $\forall x(f(x)\to g(x))$  and  $\neg g(c)$  conclude  $\neg f(c)$  (i.e. modus tollens). Additionally, we are flexible with respect to the ordering of conjuncts and disjuncts. For example, given the previous steps  $f(a)\wedge g(a)$  and  $\forall x(g(x)\land f(x)\rightarrow u(x)\lor v(x))$  we consider  $v(a)\lor u(a)$  to be valid.
A.7 Generating distractors
Implication elimination For any rule  $\forall x(f(x) \to g(x))$  in the gold proof, we generate a distractor rule  $\forall x(f(x) \to h(x))$  where the concept  $h$  is a distractor and is not helpful in completing the proof. In addition, for any ground logical form in the gold proof  $f(c)$ , we generate a distractor logical form  $h(c)$  as well as a rule  $\forall x(h(x) \to h'(x))$ . Note that the original PRONTOQA only adds a single distractor, whereas we add multiple, one for each hop in the proof.
Conjunction introduction Similar to those in implication elimination. For any rule  $\forall x(f_1(x) \land \ldots \land f_n(x) \to g(x))$ , we generate a rule of the form  $\forall x(h_1(x) \land \ldots \land h_{n-1}(x) \land f_n(x) \to g(x))$  where  $h_i$  are distractor concepts. Grounded distractor conjuncts are also generated as axioms  $h_i(c)$ , so that, given  $f_n(c)$ , both the gold rule and distractor rule are valid proof steps.
Conjunction elimination Distractors are generated similarly to the conjunction introduction case.
Disjunction introduction Distractors are generated similarly to the conjunction introduction case.
Disjunction elimination Since this deduction step has many premises, multiple distractors are necessary to ensure the model doesn't resort to heuristics. For every rule of the form  $\forall x(f_i(x) \to g(x))$ , two distractor rules are generated:  $\forall x(f_i(x) \to h'(x))$  and  $\forall x(h_i(x) \to g(x))$ . A distractor disjunction is also generated:  $h''(c) \lor h_1(c) \lor \ldots \lor h_{n-1}(c)$ .
Proof by contradiction As with disjunction elimination, multiple distractors are necessary here. We generate two distractor rules  $\forall x(f_1(x) \lor \ldots \lor f_n(x) \to h(x))$  and  $\forall x(h_1(x) \lor \ldots \lor h_n(x) \to g(x))$ . We also generate the distractor axiom  $\neg h'(c)$  so that the model is forced to choose between two axioms for the first step of the proof.
To avoid creating inconsistencies when generating a distractor rule, we avoid using existing predicates in the consequent of each rule.
$^{8}$ Analogous to the broadly-valid steps in PRONTOQA.
Algorithm 2: Pseudocode for evaluating the output chain-of-thought. Here, the comparison operations between logical forms ignore the order of conjuncts if both operands are conjunctions; and similarly for disjunctions. In addition, when iterating over previous steps in the proof, we consider them in reverse order, so that more recent steps are prioritized. The helper function negate is defined, in order of precedence: negate  $(\neg A) = A$ , negate  $(A \lor B) = \text{negate}(A) \land \text{negate}(B)$ , negate  $(A \land B) = \text{negate}(A) \lor \text{negate}(B)$ , or negate  $(A) = \neg A$ .
function evaluate_cot(context sentences  $Q_{1},\ldots ,Q_{m}$  predicted chain-of-thought sentences  $C_1,\dots,C_n$  goal sentence g)   
 $L^g =$  semantic_scan(g) /\* parse the goal \*/   
for  $i\in 1,\ldots ,m$  do /\* parse the context \*/  $L_{i}^{Q} =$  semantic_scan(Qi)   
for  $i\in 1,\ldots ,m$  do /\* parse the predicted chain-of-thought \*/  $L_{i}^{C} =$  semantic_scan(Ci)   
initialize  $S$  as an empty set, and  $H$  as an empty map   
for  $i\in 1,\ldots ,n$  do /\* reconstruct the proof from the chain-of-thought \*/ if  $L_{i}^{C}$  indicates this is a contradiction' if negate  $(L_{i + 1}^{C})\in H(L_{i - 1}^{C})$ $\begin{array}{rlr}{|}&{(P,D,k)=(\{L_{i-1}^{C},\mathrm{negate}(L_{i+1}^{C})\},\{\mathrm{negate}(L_{i+1}^{C})\},1)}\\&{\mathrm{else~continue}}\end{array}$  else  $\begin{array}{rl}{|}&{(P,D,k)=\mathrm{is\_provable}(L_i^C,\{L_1^Q,\ldots,L_m^Q\},S,H)}\\&{\mathrm{set~}H(L_i^C)=\bigcup_{p\in P}H(p)\setminus D}\\&{\mathrm{if~}k\geq 0}\\&{\mathrm{add~}L_i^C\mathrm{~to~}S}\end{array}$    
return  $L^g\in S$  /\* the proof is correct if the final conclusion is provable \*/ function is_provable(logical form  $\varphi$  set of axioms A, previous conclusions  $S_{y}$  hypothesis map H)   
if  $\varphi \in A$  return  $(\{\varphi \} ,1)$  /\* this is an axiom \*/ else if  $\varphi$  is a conjunction or disjunction initialize  $P^{\prime}$  as an empty list, and  $k^{\prime} = 0$  for  $\varphi_{i}$  operand in  $\varphi$  do  $(P,k) =$  is_provable  $(\varphi_{i},A,S,H)$  if  $\varphi$  is a conjunction if  $k\geq 0$  and the step immediately preceding  $\varphi$  in the proof is in  $P$  append  $P$  to  $P^{\prime}$  set  $k^{\prime} = k^{\prime} + k$  else break. else if  $k > 0$  and  $\varphi$  is a disjunction return  $(P,\emptyset ,k + 1)$  /\* provable by disjunction introduction \*/ if  $P^{\prime}$  has the same size as  $\varphi$  has operands return  $(\bigcup P^{\prime},\emptyset ,k^{\prime})$  /\* provable by conjunction introduction \*/ for  $a\in S\cup A$  do if a is a conjunction and  $\varphi = a_{i}$  for some i return  $(\{a\} ,\emptyset ,1 + 1\{a\in A\})$  /\* provable by conjunction elimination \*/ else if a has form  $\forall x(\psi \rightarrow \gamma)$  where  $\gamma [x\mapsto c] = \varphi$ $(P,k) =$  is_provable  $(\psi [x\mapsto c],A,S,H)$  if  $k\geq 0$  and the step immediately preceding  $\varphi$  in the proof is in  $P\cup \{a\}$  return  $(P\cup \{a\} ,\emptyset ,k + 1\{a\in A\})$  /\* provable by conjunction elimination \*/ for  $s\in S$  where s is a disjunction do if for all disjuncts  $s_i$  there is a  $s_j\in S$  such that  $s_j = \varphi$  and  $s_i\in H(s_j)$  return  $(\{s_j\} ,\{s_i\} ,1)$  /\* provable by disjunction elimination \*/
Algorithm 2: (continued from previous page)
for  $a\in S\cup A$  do   
if a has form  $\forall x(\psi \rightarrow \gamma)$  where  $\gamma [x\mapsto c] = \varphi$ $(P,k) =$  is_provable  $(\psi [x\mapsto c],A,S,H)$    
if  $k\geq 0$  and the step immediately preceding  $\varphi$  in the proof is in  $P\cup \{a\}$    
return  $(P\cup \{a\} ,\emptyset ,k + 1\{a\in A\})$  /\* provable by implication elimination \*/   
else if a has form  $\forall x(\psi \to \gamma)$  where negate  $(\psi [x\mapsto c]) = \varphi$ $(P,k) =$  is_provable(negate  $(\gamma [x\mapsto c]),A,S,H)$    
if  $k\geq 0$  and the step immediately preceding  $\varphi$  in the proof is in  $P\cup \{a\}$    
/\* provable with additional deduction rules (modus tollens) \*/   
return  $(P\cup \{a\} ,\emptyset ,k + 1\{a\in A\})$    
if  $\varphi \in S$    
return  $(\{\varphi \} ,\emptyset ,0)$  /\* proved by previous step \*/   
else if  $\varphi$  has form  $\forall x(\psi \rightarrow \gamma)$    
/\* note: we precompute this graph \*/   
let  $G$  be the graph where for any axiom in  $A$  with form  $\forall x(\alpha \rightarrow \beta),\alpha$  and  $\beta$  are vertices and there is a directed edge from  $\alpha$  to  $\beta$    
if there is a path in  $G$  from  $\psi$  to  $\gamma$    
/\* provable with additional deduction rules \*/   
return (axioms corresponding to path edges,  $\varnothing$  ,length of path )   
return  $(\emptyset ,\emptyset , - 1)$  /\* this step is not provable (i.e., invalid) \*/