Skip to content

Commit 91a7b2c

Browse files
levineuwirthclaude
andcommitted
R-11: cong over built-in operators (the operator-congruence payoff)
Mirror of Lean #51. Real cvc5 LIA traces use [cong] to lift argument equalities through built-in operators (not / + / <=), not just UF symbols. This is the congruence shape that lets a real alethe-2024 trace walk end-to-end instead of falling through to lia -- the capability the whole arc was building toward, now wired live via R-9. No elaborator change was needed. The plan budgeted a Constr-level refactor of elab_cong here, but it landed early in R-5: because Coq has no mkCongr, elab_cong was open-coded at the Constr level from the start (translate LHS/RHS via sexp_to_constr, peel the app spine via decompose_app, per-argument f_equal + eq_trans chain). Operator heads (Zadd / Zle / not) decompose exactly like UF heads -- no UF-specific assumption anywhere in the elaborator. Three tests confirm the operator cases: - cong over not (unary, Prop -> Prop) - cong over + (binary over Z) - cong over <= (binary, predicate-valued: result type Prop, the constant arg carried by a refl premise) All axiom-free (cong is f_equal / eq_trans / eq_refl). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6541d49 commit 91a7b2c

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

rocq-bridge/theories/Test.v

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,3 +1240,63 @@ Qed.
12401240

12411241
Print alethe_walker_equiv_pos2_axiom_free.
12421242
Print Assumptions alethe_walker_equiv_pos2_axiom_free.
1243+
1244+
(** Alethe walker — R-11 cong over built-in operators.
1245+
1246+
Mirror of lean-bridge/Test/Tactic.lean's cong-over-operator
1247+
tests (Lean #51). Real cvc5 LIA traces use [cong] to lift
1248+
argument equalities through built-in operators ([not], [+],
1249+
[<=], …), not just UF symbols — this is the congruence shape
1250+
that lets a real alethe-2024 trace walk end-to-end rather than
1251+
fall through to [lia]. No elaborator change was needed: the
1252+
Constr-level [elab_cong] (built that way since R-5, as Coq has
1253+
no [mkCongr]) already translates operator-headed lists via
1254+
[sexp_to_constr] and peels the spine via [decompose_app] —
1255+
operator heads ([Zadd]/[Zle]/[not]) decompose exactly like UF
1256+
heads. All axiom-free: [cong] is [f_equal]/[eq_trans]/[eq_refl]. *)
1257+
1258+
(* cong over [not] (unary Prop operator): (~a) = (~b) from a = b. *)
1259+
Theorem alethe_walker_cong_not_axiom_free :
1260+
forall (a b : Prop), a = b -> (~ a) = (~ b).
1261+
Proof.
1262+
intros a b h.
1263+
alethe_walker_test "(
1264+
(assume a0 (= a b))
1265+
(step t0 (cl (= (not a) (not b))) :rule cong :premises (a0)) )".
1266+
Qed.
1267+
1268+
Print alethe_walker_cong_not_axiom_free.
1269+
Print Assumptions alethe_walker_cong_not_axiom_free.
1270+
1271+
(* cong over [+] (binary operator over Z): x + z = y + w from
1272+
x = y and z = w. The shape cvc5 emits lifting arg equalities
1273+
through an addition during LIA normalization. *)
1274+
Theorem alethe_walker_cong_add_axiom_free :
1275+
forall (x y z w : Z), x = y -> z = w -> x + z = y + w.
1276+
Proof.
1277+
intros x y z w h1 h2.
1278+
alethe_walker_test "(
1279+
(assume a0 (= x y))
1280+
(assume a1 (= z w))
1281+
(step t0 (cl (= (+ x z) (+ y w))) :rule cong :premises (a0 a1)) )".
1282+
Qed.
1283+
1284+
Print alethe_walker_cong_add_axiom_free.
1285+
Print Assumptions alethe_walker_cong_add_axiom_free.
1286+
1287+
(* cong over [<=] (binary comparison, predicate-valued): the
1288+
conclusion's equality is between two Props, exercising the
1289+
per-argument chain when the operator's result type is Prop.
1290+
The constant 5 position is carried by a [refl] premise. *)
1291+
Theorem alethe_walker_cong_le_axiom_free :
1292+
forall (x y : Z), x = y -> (x <= 5)%Z = (y <= 5)%Z.
1293+
Proof.
1294+
intros x y h.
1295+
alethe_walker_test "(
1296+
(assume a0 (= x y))
1297+
(step t_refl (cl (= 5 5)) :rule refl)
1298+
(step t0 (cl (= (<= x 5) (<= y 5))) :rule cong :premises (a0 t_refl)) )".
1299+
Qed.
1300+
1301+
Print alethe_walker_cong_le_axiom_free.
1302+
Print Assumptions alethe_walker_cong_le_axiom_free.

tools/axiom_allowlist.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,12 @@
535535
"alethe_walker_equiv_pos1_axiom_free":
536536
["classic"],
537537
"alethe_walker_equiv_pos2_axiom_free":
538-
["classic"]
538+
["classic"],
539+
"alethe_walker_cong_not_axiom_free":
540+
[],
541+
"alethe_walker_cong_add_axiom_free":
542+
[],
543+
"alethe_walker_cong_le_axiom_free":
544+
[]
539545
}
540546
}

0 commit comments

Comments
 (0)