You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Unsound: the paths of the core theories can be taken by user theories #1249
The built-in reduction of integer, real and map operators and the translation to Why3 recognise these operators by their path: op_kind (src/ecFol.ml) and core_theories (src/ecSmt.ml) look up Top.CoreInt.lt, Top.CoreInt.add, etc. But the prelude only loads Pervasive, Tactics and Logic, so nothing prevents a user from defining a theory at one of these paths with other definitions. The reduction and the SMT translation then give these operators the meaning of the core ones.
Minimal working example
No require, no axiom, no SMT:
theory CoreInt.
op lt (x y : int) : bool = true.
end CoreInt.
(* No SMT: the built-in reduction of integer comparisons is keyed by
the path Top.CoreInt.lt as well. *)
lemma l2 : !CoreInt.lt 1 0.
proof. by simplify. qed.
lemma l1 : CoreInt.lt 1 0.
proof. by delta. qed.
lemma bad : false.
proof. by have := l2; rewrite l1. qed.
print axiom bad.
The same holds with smt() in place of simplify for l2. The other core theories (CoreReal, CoreMap, ...) are presumably affected as well.
Possible fix
Reserve the names of the core theories (reject theory and require ... as with these names outside the system library), or bind the core theories in the prelude so that defining them again raises DuplicatedBinding.
There might be similar problems with other tactics that hardcode objects from outside the prelude. Rewrite Pr is one example, but I'm sure there are others.
It's not just core theories either. There are for example places where we hardcode StdBigop.Bigreal.BRA.big. One instance is in rewrite Pr (mu_has_le), but that one isn't easily exploitable due to an internal typing error. I found an exploitable instance using the fel tactic:
Click to expand code
require import Int Real List.
(* user provided "Core" theories *)
theory FelTactic.
end FelTactic.
theory StdBigop.
theory Bigreal.
theory BRA.
op big ['a] (P: 'a -> bool) (F: 'a -> real) (r: 'a list): real = 0%r.
end BRA.
end Bigreal.
end StdBigop.
(* setting up example *)
module type OT = {proc incr(): unit}.
module type Adv(O: OT) = {proc a(): unit}.
module Exp(A:Adv) = {
var c: int
module O = {
proc incr() = {c <- c + 1;}
}
proc main(): unit = {
c <- 0;
A(O).a();
}
}.
module (Once: Adv) (O: OT) = {
proc a() ={
O.incr();
}
}.
lemma L_real &m:
Pr[Exp(Once).main() @ &m : Exp.c = 1]
= 1%r.
proof.
byphoare => //.
proc.
inline.
auto.
qed.
(* bug starts here *)
lemma L_bad &m:
Pr[Exp(Once).main() @ &m : Exp.c = 1]
<= 0%r.
proof.
fel 1 (Exp.c) (fun x, 1%r) 1 (Exp.c = 1) []=> //.
- inline; auto.
move => c.
proc; auto => /> /#.
qed.
lemma bad: false.
proof.
suff: forall &m, false by done.
move => &m.
have L_bad:=L_bad &m.
by rewrite (L_real &m) in L_bad.
qed.
Activity
oskgo commentedon Nov 29, 2026
There might be similar problems with other tactics that hardcode objects from outside the prelude. Rewrite Pr is one example, but I'm sure there are others.
oskgo commentedon Nov 30, 2026
Yup:
oskgo commentedon Dec 1, 2026
It's not just core theories either. There are for example places where we hardcode
StdBigop.Bigreal.BRA.big. One instance is in rewrite Pr (mu_has_le), but that one isn't easily exploitable due to an internal typing error. I found an exploitable instance using thefeltactic:Click to expand code