-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve inequality offset support theorems for
grind
This PR improves the theorems used to justify the steps performed by the inequality offset module. See new test for examples of how they are going to be used.
- Loading branch information
1 parent
a6789a7
commit de2f4e2
Showing
2 changed files
with
88 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Lean | ||
|
||
elab tk:"#R[" ts:term,* "]" : term => do | ||
let ts : Array Lean.Syntax := ts | ||
let es ← ts.mapM fun stx => Lean.Elab.Term.elabTerm stx none | ||
if h : 0 < es.size then | ||
return (Lean.RArray.toExpr (← Lean.Meta.inferType es[0]!) id (Lean.RArray.ofArray es h)) | ||
else | ||
throwErrorAt tk "RArray cannot be empty" | ||
|
||
open Lean.Grind.Offset | ||
|
||
macro "C[" "#" x:term:max " ≤ " "#" y:term:max "]" : term => `({ x := $x, y := $y : Cnstr }) | ||
macro "C[" "#" x:term:max " + " k:term:max " ≤ " "#" y:term:max "]" : term => `({ x := $x, y := $y, k := $k : Cnstr }) | ||
macro "C[" "#" x:term:max " ≤ " "#"y:term:max " + " k:term:max "]" : term => `({ x := $x, y := $y, k := $k, l := false : Cnstr }) | ||
|
||
example (x y z : Nat) : x + 2 ≤ y → y ≤ z → z + 1 ≤ x → False := | ||
Cnstrs.unsat #R[x, y, z] [ | ||
C[ #0 + 2 ≤ #1 ], | ||
C[ #1 ≤ #2 ], | ||
C[ #2 + 1 ≤ #0 ] | ||
] rfl | ||
|
||
example (x y z w : Nat) : x + 2 ≤ y → y ≤ z → z ≤ w + 7 → x ≤ w + 5 := | ||
Cnstrs.imp #R[x, y, z, w] [ | ||
C[ #0 + 2 ≤ #1 ], | ||
C[ #1 ≤ #2 ], | ||
C[ #2 ≤ #3 + 7] | ||
] | ||
C[ #0 ≤ #3 + 5 ] | ||
rfl |