Skip to content

Commit 83ad3a2

Browse files
committed
feat: internalize offset terms
1 parent 17079a2 commit 83ad3a2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Lean/Meta/Tactic/Grind/Order/Assert.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Adds an edge `u --(k) --> v` justified by the proof term `p`, and then
221221
if no negative cycle was created, updates the shortest distance of affected
222222
node pairs.
223223
-/
224-
def addEdge (u : NodeId) (v : NodeId) (k : Weight) (h : Expr) : OrderM Unit := do
224+
public def addEdge (u : NodeId) (v : NodeId) (k : Weight) (h : Expr) : OrderM Unit := do
225225
if (← isInconsistent) then return ()
226226
if u == v then
227227
if k.isNeg then

src/Lean/Meta/Tactic/Grind/Order/Internalize.lean

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ prelude
88
public import Lean.Meta.Tactic.Grind.Order.OrderM
99
import Init.Data.Int.OfNat
1010
import Init.Grind.Module.Envelope
11+
import Init.Grind.Order
1112
import Lean.Meta.Tactic.Grind.Arith.CommRing.SafePoly
1213
import Lean.Meta.Tactic.Grind.Arith.CommRing.Reify
1314
import Lean.Meta.Tactic.Grind.Arith.CommRing.DenoteExpr
@@ -16,6 +17,7 @@ import Lean.Meta.Tactic.Grind.Arith.Cutsat.Nat
1617
import Lean.Meta.Tactic.Grind.Order.StructId
1718
import Lean.Meta.Tactic.Grind.Order.Util
1819
import Lean.Meta.Tactic.Grind.Order.Assert
20+
import Lean.Meta.Tactic.Grind.Order.Proof
1921
namespace Lean.Meta.Grind.Order
2022

2123
open Arith CommRing
@@ -265,12 +267,14 @@ def toOffsetTerm? (e : Expr) : OrderM (Option OffsetTermResult) := do
265267

266268
def internalizeTerm (e : Expr) : OrderM Unit := do
267269
let some r ← toOffsetTerm? e | return ()
268-
let _ ← mkNode e
269-
let _ ← mkNode r.a
270-
-- **TODO**:
271-
-- trace[Meta.debug] "e: {e}, a: {r.a}, k: {r.k}"
272-
-- check r.h
273-
return ()
270+
let x ← mkNode e
271+
let y ← mkNode r.a
272+
let h₁ ← mkOrdRingPrefix ``Grind.Order.le_of_offset_eq_1_k
273+
let h₁ := mkApp4 h₁ e r.a (toExpr r.k) r.h
274+
addEdge x y { k := r.k } h₁
275+
let h₂ ← mkOrdRingPrefix ``Grind.Order.le_of_offset_eq_2_k
276+
let h₂ := mkApp4 h₂ e r.a (toExpr r.k) r.h
277+
addEdge y x { k := -r.k } h₂
274278

275279
def updateTermMap (e eNew h : Expr) : GoalM Unit := do
276280
modify' fun s => { s with

0 commit comments

Comments
 (0)