Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2bfa11b
Sketch text: a composite glyph is the union of its components' region…
claude Nov 23, 2026
932e257
verify/forge-text: sketch text's Lean specs (core only; not built her…
claude Nov 23, 2026
f1894bd
Cargo workspace: verify/forge-text is a Lean project, out of the work…
claude Nov 23, 2026
505b4a1
research/sketch-text/gate-layout-diff.txt: the exact gate per functio…
claude Nov 23, 2026
de4c43f
verify/forge-text: built (Lean 4.36, core only, standard axioms); dec…
claude Nov 23, 2026
9fee20b
verify/forge-text: WindingIsTopological proven from verify/winding2d …
claude Nov 23, 2026
7b2bd24
forge-lang fonts: every shipped contour is simple in winding2d's sens…
claude Nov 23, 2026
65b236d
forge-font: the simple-glyph reader and contour walk as an integer co…
claude Nov 23, 2026
2d70a15
verify/aeneas/forge-font: glyf_core's contour walk proven against ver…
claude Nov 23, 2026
60964b0
verify/aeneas/forge-font: read_simple proven (never fails on any byte…
claude Nov 23, 2026
063a9e0
verify/aeneas/forge-sketch: winding::line translated (2 definitions; …
claude Nov 23, 2026
be95022
forge-font: the Type 2 charstring machine as an integer core (cff_cor…
claude Nov 23, 2026
326b5b7
forge-font: cff_core's charstring loop proven (run_spec: for any byte…
claude Nov 23, 2026
23bc2e0
verify/aeneas/forge-sketch: L5 started on verify/ieee754: one de Cast…
claude Nov 23, 2026
dd8d14e
forge-sketch winding: size bezier's rounding margin by the root piece…
claude Nov 23, 2026
d8e3762
Merge commit '9cc03e3' into claude/repo-review-mbdrlj-sketch-text
claude Nov 23, 2026
668c026
verify/aeneas/forge-sketch: retranslated after round 6 (orient2d's so…
claude Nov 23, 2026
5557c8f
forge-font: place a glyf outline by hmtx lsb - xMin, as FreeType and …
claude Nov 23, 2026
eadf348
Merge remote-tracking branch 'origin/main' into claude/repo-review-mb…
claude Nov 23, 2026
0870264
forge-font: cargo fmt after merging main
claude Nov 23, 2026
4cea860
aeneas: regenerate forge-font translation
David-Bascom05 Nov 23, 2026
589c390
Merge origin/main into #19
David-Bascom05 Nov 23, 2026
cbed8d0
verify/aeneas/forge-font: one_spec back inside the default heartbeats…
David-Bascom05 Nov 23, 2026
17dce34
Merge remote-tracking branch 'origin/main' into HEAD
David-Bascom05 Nov 26, 2026
cd47085
Keep holes in ordinary loop lists and check dependent text proofs
David-Bascom05 Nov 26, 2026
90374fb
Merge remote-tracking branch 'origin/main' into HEAD
David-Bascom05 Nov 26, 2026
b23ecc5
Refresh the sketch translation source location emitted by Aeneas
David-Bascom05 Nov 26, 2026
30af983
Scan subdivision leaf boundaries without three temporary vectors per …
David-Bascom05 Nov 26, 2026
9f5e094
Keep the buffered classifier for one train and compare adversarial le…
David-Bascom05 Nov 26, 2026
34b9026
Avoid empty per-entity allocations and temporary profiles on ordinary…
David-Bascom05 Nov 26, 2026
f380da6
Normalize a single checked profile directly and refresh translated so…
David-Bascom05 Nov 26, 2026
4beb021
Use the shared floating-point min/max model in the sketch proof
David-Bascom05 Nov 26, 2026
9784df2
Skip endpoint comparisons for disjoint sketch curves
David-Bascom05 Nov 26, 2026
f6aaf23
Use the shared Vec.clear model in the font proof
David-Bascom05 Nov 26, 2026
19cf57c
Reserve the known face-run and wall buffers before geometry evaluation
David-Bascom05 Nov 26, 2026
f7efcc4
Allocate each face query once for its known coedge count
David-Bascom05 Nov 26, 2026
724ac7e
Merge commit 'd991b4c4d5f59c07fafb1e0b3d226f37bb44702b' into HEAD
David-Bascom05 Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/aeneas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ on:
# what the verify/aeneas/*/lean packages require from outside verify/aeneas (lakefile paths)
"research/kernel-audit/float-verification/**", "research/spline-loops/fp/**",
"verify/forge-exact/**", "verify/forge-machine/**", "verify/forge-cam/**",
"verify/forge-topo-check/**", "verify/sheet/**",
"verify/forge-topo-check/**", "verify/sheet/**", "verify/forge-text/**", "verify/winding2d/**",
".github/workflows/aeneas.yml"]
pull_request:
paths: ["kernel/**", "verify/aeneas/**", "verify/ieee754/**", "tools/aeneas/**",
# what the verify/aeneas/*/lean packages require from outside verify/aeneas (lakefile paths)
"research/kernel-audit/float-verification/**", "research/spline-loops/fp/**",
"verify/forge-exact/**", "verify/forge-machine/**", "verify/forge-cam/**",
"verify/forge-topo-check/**", "verify/sheet/**",
"verify/forge-topo-check/**", "verify/sheet/**", "verify/forge-text/**", "verify/winding2d/**",
".github/workflows/aeneas.yml"]
workflow_dispatch:

Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/lean-forge-text.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Sketch text's Lean claims (verify/forge-text/lean): the placed outline is the font's, the
# winding rule, a text's region as the union of its glyphs' parts. `lake build` on the pinned
# toolchain (core Lean only, no Mathlib), then the axiom check: a `sorry`, `native_decide` or any
# axiom past propext, Classical.choice and Quot.sound fails the job.
name: lean-forge-text

on:
push:
branches: [main]
paths: ["verify/forge-text/**", "verify/winding2d/**", "kernel/forge-font/src/**", "kernel/forge-sketch/src/winding.rs",
".github/workflows/lean-forge-text.yml"]
pull_request:
paths: ["verify/forge-text/**", "verify/winding2d/**", "kernel/forge-font/src/**", "kernel/forge-sketch/src/winding.rs",
".github/workflows/lean-forge-text.yml"]
workflow_dispatch:

jobs:
proofs:
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: verify/forge-text/lean
steps:
- uses: actions/checkout@v4
- name: elan and the pinned toolchain
run: |
curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -o elan-init.sh
sh elan-init.sh -y --default-toolchain none
echo "$HOME/.elan/bin" >> "$GITHUB_PATH"
"$HOME/.elan/bin/elan" toolchain install "$(cat lean-toolchain)"
- name: build and axioms
run: |
lake build
Comment on lines +32 to +34

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run dependent proof bridges on specification-only changes

When a PR changes only verify/forge-text/** or verify/winding2d/**, this workflow builds the specification package but not the new ForgeFont and ForgeSketch bridges that import it. The existing .github/workflows/aeneas.yml path filters include neither directory, so that workflow does not run either. Consequently, specification changes can pass all triggered proof checks while breaking contour_spec or line_spec. Add these new dependency paths to the Aeneas workflow filters, or build the dependent bridge packages here.

Useful? React with 👍 / 👎.

lake env lean Axioms.lean | tee axioms.txt
! grep -E "sorryAx|ofReduceBool" axioms.txt
19 changes: 15 additions & 4 deletions interface/forge-lang/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ pub(crate) fn mk_ent(sk: &Rc<RefCell<Sk>>, id: EntityId) -> Value {
sk: sk.clone(),
id,
kind,
loop_segs: Rc::new(vec![]),
loop_segs: Ent::no_segments(),
})
}

Expand Down Expand Up @@ -1747,7 +1747,8 @@ pub(crate) fn profile_of(
/// A profile argument's sketch, its regions, and the entities they were taken from.
type Regions = (Rc<RefCell<Sk>>, Vec<forge_ops::Profile>, Vec<EntityId>);

/// The regions a list of loops of one sketch (a sketch text) bound, only they.
/// Ordinary loops nest together. A text glyph groups its own components so overlapping
/// components within a glyph are filled while adjacent glyphs remain distinct.
pub(crate) fn profiles_of(xs: &[Value], span: Span) -> R<Regions> {
let mut sk: Option<Rc<RefCell<Sk>>> = None;
let mut ids = Vec::new();
Expand Down Expand Up @@ -1782,7 +1783,17 @@ pub(crate) fn profiles_of(xs: &[Value], span: Span) -> R<Regions> {
want: Ty::Sketch,
found: Ty::List,
})?;
let ps = sk.borrow().profiles_among(&ids, span)?;
let sketch = sk.borrow();
let ps = if sketch.text_segs.is_empty() {
sketch.profiles_among(&ids, span)?
} else {
let elements = xs.iter().filter_map(|x| match x {
Value::Ent(e) => Some(e.loop_segs.as_slice()),
_ => None,
});
sketch.profiles_grouped(elements, span)?
};
drop(sketch);
Ok((sk, ps, ids))
}

Expand Down Expand Up @@ -3050,7 +3061,7 @@ pub fn member(ev: &mut Eval, v: Value, name: &str, span: Span) -> R<Value> {
sk: e.sk.clone(),
id,
kind: EntKind::Point,
loop_segs: Rc::new(vec![]),
loop_segs: Ent::no_segments(),
})
};
use forge_sketch::Entity as E;
Expand Down
10 changes: 9 additions & 1 deletion interface/forge-lang/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ pub struct Ent {
pub loop_segs: Rc<Vec<EntityId>>,
}

impl Ent {
/// Points and individual curves all have the same empty segment list.
pub(crate) fn no_segments() -> Rc<Vec<EntityId>> {
thread_local! { static EMPTY: Rc<Vec<EntityId>> = Rc::new(Vec::new()); }
EMPTY.with(Rc::clone)
}
}

impl std::fmt::Debug for Ent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Ent({:?} {:?})", self.kind, self.id)
Expand Down Expand Up @@ -1879,7 +1887,7 @@ impl<'s> Eval<'s> {
sk: en.sk.clone(),
id,
kind,
loop_segs: Rc::new(vec![]),
loop_segs: Ent::no_segments(),
}));
}
o => {
Expand Down
13 changes: 13 additions & 0 deletions interface/forge-lang/src/feat_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ pub enum TextProblem {
NoLineSpacing,
/// Nothing of the string is drawn (it is empty, or only spaces).
Empty,
/// The glyphs of these two characters (places in the string) cross or touch: set them apart
/// (`spacing:`, or another font or string).
GlyphsMeet { a: usize, b: usize },
}

#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -208,6 +211,9 @@ impl FeatError {
TextProblem::Font(why) => format!("the font: {why}"),
TextProblem::NoLineSpacing => "several lines, and the font gives no line spacing".into(),
TextProblem::Empty => "nothing of the text is drawn (it is empty, or only spaces)".into(),
TextProblem::GlyphsMeet { a, b } => format!(
"the glyphs of characters {a} and {b} of the text cross or touch: set them apart with spacing: (a length added after each character)"
),
},
File { file, problem, .. } => match problem {
FileProblem::Missing => format!("{file}: not found beside the part file"),
Expand Down Expand Up @@ -264,6 +270,13 @@ impl FeatError {
TextProblem::Font(why) => vec![p("Font"), ("why", s(why))],
TextProblem::NoLineSpacing => vec![p("NoLineSpacing")],
TextProblem::Empty => vec![p("Empty")],
TextProblem::GlyphsMeet { a, b } => {
vec![
p("GlyphsMeet"),
("a", (*a as f64).into()),
("b", (*b as f64).into()),
]
}
}
}
File { file, problem, .. } => vec![
Expand Down
228 changes: 227 additions & 1 deletion interface/forge-lang/src/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,236 @@ mod tests {
let _ = f.outline(g);
let _ = f.advance(g);
}
let _ = forge_font::layout::lay_out(&f, "Fuzz 0\nSecond", forge_font::layout::Align::Center);
let _ =
forge_font::layout::lay_out(&f, "Fuzz 0\nSecond", forge_font::layout::Align::Center, 7.0);
}
});
assert!(shipped("Source Sans 3", true, false).is_none());
assert!(shipped("Open Sans", false, true).is_none());
}
}

/// Every contour of the shipped faces over Latin-1 is simple in winding2d's sense
/// (verify/forge-text, `winding_is_topological`): no two pieces that are not neighbours meet,
/// and neighbours meet only at their shared end. Pieces are split at their middle until their
/// control boxes are apart by more than the splits' rounding; at a shared end the two end pieces'
/// control points must lie in cones from that end that share no direction (exact orient2d), the
/// curves lying in their hulls. Any contour that does not come apart within the splits allowed is
/// named.
#[cfg(test)]
mod simple {
use super::*;
use forge_font::Seg;
use forge_math::Point2;
use forge_math::predicates::orient2d;

const DEPTH: usize = 28;

fn split(p: &[Point2]) -> (Vec<Point2>, Vec<Point2>) {
let mut rows = p.to_vec();
let n = p.len();
let (mut l, mut r) = (vec![rows[0]], vec![rows[n - 1]]);
for k in 1..n {
for i in 0..n - k {
rows[i] = Point2::new(
(rows[i].x + rows[i + 1].x) / 2.0,
(rows[i].y + rows[i + 1].y) / 2.0,
);
}
l.push(rows[0]);
r.push(rows[n - 1 - k]);
}
r.reverse();
(l, r)
}

fn bbox(p: &[Point2]) -> (Point2, Point2) {
p.iter().fold(
(
Point2::new(f64::INFINITY, f64::INFINITY),
Point2::new(f64::NEG_INFINITY, f64::NEG_INFINITY),
),
|(lo, hi), q| {
(
Point2::new(lo.x.min(q.x), lo.y.min(q.y)),
Point2::new(hi.x.max(q.x), hi.y.max(q.y)),
)
},
)
}

/// The two boxes are apart by more than `m`.
fn apart(a: &[Point2], b: &[Point2], m: f64) -> bool {
let ((al, ah), (bl, bh)) = (bbox(a), bbox(b));
ah.x + m < bl.x || bh.x + m < al.x || ah.y + m < bl.y || bh.y + m < al.y
}

/// The control points of `a` and of `b` (all but `j`, their shared end) lie in cones from `j`
/// sharing no direction: a line through `j` along one of the rays has all of one strictly on
/// one side (or on that ray), all of the other strictly on the other.
fn cones_apart(j: Point2, a: &[Point2], b: &[Point2]) -> bool {
let (ua, ub): (Vec<Point2>, Vec<Point2>) = (
a.iter().copied().filter(|&p| p != j).collect(),
b.iter().copied().filter(|&p| p != j).collect(),
);
if ua.is_empty() || ub.is_empty() {
return false;
}
let side = |r: Point2, p: Point2| orient2d(j, r, p);
for (mine, other) in [(&ua, &ub), (&ub, &ua)] {
for &r in mine.iter() {
// the ray j -> r: one cone on it or left (or right), the other strictly the other way
for s in [1.0, -1.0] {
let mine_ok = mine
.iter()
.all(|&p| s * side(r, p) >= 0.0 && (side(r, p) != 0.0 || (p - j).dot(r - j) > 0.0));
// strictly the other side, or on the opposite ray (a straight continuation)
let other_ok = other
.iter()
.all(|&p| s * side(r, p) < 0.0 || (side(r, p) == 0.0 && (p - j).dot(r - j) < 0.0));
if mine_ok && other_ok {
return true;
}
}
}
}
false
}

/// Whether pieces `a` and `b` (control points) meet only at the shared ends `joints`.
fn only_at(a: &[Point2], b: &[Point2], joints: &[Point2], m: f64, depth: usize) -> bool {
let ja: Vec<Point2> = joints
.iter()
.copied()
.filter(|j| a.first() == Some(j) || a.last() == Some(j))
.collect();
let shared: Vec<Point2> = ja
.iter()
.copied()
.filter(|j| b.first() == Some(j) || b.last() == Some(j))
.collect();
if shared.is_empty() && apart(a, b, m) {
return true;
}
if let [j] = shared[..]
&& cones_apart(j, a, b)
{
return true;
}
if depth == 0 {
return false;
}
let ((a0, a1), (b0, b1)) = (split(a), split(b));
[(&a0, &b0), (&a0, &b1), (&a1, &b0), (&a1, &b1)]
.iter()
.all(|(x, y)| only_at(x, y, joints, m, depth - 1))
}

fn pts(s: &Seg) -> Vec<Point2> {
s.points()
}

/// One contour: at least three pieces, none a point, non-neighbours apart, neighbours meeting
/// only at their shared end.
fn simple_contour(contour: &[Seg]) -> bool {
let n = contour.len();
let ps: Vec<Vec<Point2>> = contour.iter().map(pts).collect();
let big = ps
.iter()
.flatten()
.fold(1.0f64, |m, p| m.max(p.x.abs()).max(p.y.abs()));
// the splits' rounding: a few units in the last place of the largest coordinate
let m = 64.0 * f64::EPSILON * big;
n >= 3
&& (0..n).all(|i| ps[i].first() != ps[i].last())
&& (0..n).all(|i| {
(i + 1..n).all(|j| {
let mut joints = Vec::new();
if j == i + 1 {
joints.push(contour[i].end());
}
if i == 0 && j == n - 1 {
joints.push(contour[0].start());
}
only_at(&ps[i], &ps[j], &joints, m, DEPTH)
})
})
}

/// The check fails where it should: a contour pinched at a point two non-neighbouring sides
/// share, one with a side touching another's interior, one doubling back on itself.
#[test]
fn the_check_finds_touches() {
let p = Point2::new;
let poly = |v: &[(f64, f64)]| -> Vec<Seg> {
(0..v.len())
.map(|k| {
Seg::Line(
p(v[k].0, v[k].1),
p(v[(k + 1) % v.len()].0, v[(k + 1) % v.len()].1),
)
})
.collect()
};
assert!(simple_contour(&poly(&[
(0.0, 0.0),
(4.0, 0.0),
(4.0, 4.0),
(0.0, 4.0)
])));
assert!(simple_contour(&poly(&[
(0.0, 0.0),
(2.0, 0.0),
(4.0, 0.0),
(4.0, 4.0),
(0.0, 4.0)
])));
assert!(!simple_contour(&poly(&[
(0.0, 0.0),
(4.0, 0.0),
(2.0, 2.0),
(4.0, 4.0),
(0.0, 4.0),
(2.0, 2.0)
])));
assert!(!simple_contour(&poly(&[
(0.0, 0.0),
(4.0, 0.0),
(4.0, 4.0),
(2.0, 0.0),
(0.0, 4.0)
])));
assert!(!simple_contour(&poly(&[
(0.0, 0.0),
(4.0, 0.0),
(2.0, 0.0),
(2.0, 4.0)
])));
// a quadratic touching a side
let q = vec![
Seg::Line(p(0.0, 0.0), p(4.0, 0.0)),
Seg::Quad(p(4.0, 0.0), p(2.0, -4.0), p(0.0, 4.0)),
Seg::Line(p(0.0, 4.0), p(0.0, 0.0)),
];
assert!(!simple_contour(&q));
}

#[test]
fn shipped_contours_are_simple() {
let mut bad = Vec::new();
for (family, style) in faces() {
let f = shipped(family, style.contains("Bold"), false).expect("shipped");
for c in (0x21u32..0x7f).chain(0xa1..0x100).filter_map(char::from_u32) {
if c == '\u{ad}' {
continue;
}
for (k, contour) in f.outline(f.glyph(c)).expect("outline").iter().enumerate() {
if !simple_contour(contour) {
bad.push(format!("{family} {style} {c:?} contour {k}"));
}
}
}
}
assert!(bad.is_empty(), "contours not simple: {bad:?}");
}
}
Loading
Loading