-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start using aesop in scalar_tac * Update the Lean dependencies * Start adding some utilities for Aesop * Update intTac to use Aesop.saturate * Make progress on updating scalar_tac to use aesop * Start updating Lean to v4.10.0-rc1 * Update the tests * Make progress on scalar_tac * Update the dependencies * Update the dependencies * Update the proofs in the Lean standard library * Update the dependencies in the Lean tests * Use scalar_tac patterns in the proof of the hashmap * Make minor modifications * Add options and persistent extensions to add more rule sets for scalar_tac
- Loading branch information
Showing
16 changed files
with
232 additions
and
339 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import Base.Arith.Int | ||
import Base.Arith.Scalar | ||
import Base.Arith.Lemmas |
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,40 @@ | ||
import Base.Extensions | ||
import Aesop | ||
open Lean | ||
|
||
/-! | ||
# Scalar tac rules sets | ||
This module defines several Aesop rule sets and options which are used by the | ||
`scalar_tac` tactic. Aesop rule sets only become visible once the file in which | ||
they're declared is imported, so we must put this declaration into its own file. | ||
-/ | ||
|
||
namespace Arith | ||
|
||
declare_aesop_rule_sets [Aeneas.ScalarTac, Aeneas.ScalarTacNonLin] | ||
|
||
#check Lean.Option.register | ||
register_option scalarTac.nonLin : Bool := { | ||
defValue := false | ||
group := "" | ||
descr := "Activate the use of a set of lemmas to reason about non-linear arithmetic by `scalar_tac`" | ||
} | ||
|
||
-- The sets of rules that `scalar_tac` should use | ||
open Extensions in | ||
initialize scalarTacRuleSets : ListDeclarationExtension Name ← do | ||
mkListDeclarationExtension `scalarTacRuleSetsList | ||
|
||
def scalarTacRuleSets.get : MetaM (List Name) := do | ||
pure (scalarTacRuleSets.getState (← getEnv)) | ||
|
||
-- Note that the changes are not persistent | ||
def scalarTacRuleSets.set (names : List Name) : MetaM Unit := do | ||
let _ := scalarTacRuleSets.setState (← getEnv) names | ||
|
||
-- Note that the changes are not persistent | ||
def scalarTacRuleSets.add (name : Name) : MetaM Unit := do | ||
let _ := scalarTacRuleSets.modifyState (← getEnv) (fun ls => name :: ls) | ||
|
||
end Arith |
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 Base.Arith.Int | ||
import Base.Arith.Scalar | ||
|
||
@[nonlin_scalar_tac n % m] | ||
theorem Int.emod_of_pos_disj (n m : Int) : m ≤ 0 ∨ (0 ≤ n % m ∧ n % m < m) := by | ||
if h: 0 < m then | ||
right; constructor | ||
. apply Int.emod_nonneg; omega | ||
. apply Int.emod_lt_of_pos; omega | ||
else left; omega | ||
|
||
theorem Int.pos_mul_pos_is_pos (n m : Int) (hm : 0 ≤ m) (hn : 0 ≤ n): 0 ≤ m * n := by | ||
have h : (0 : Int) = 0 * 0 := by simp | ||
rw [h] | ||
apply mul_le_mul <;> norm_cast | ||
|
||
@[nonlin_scalar_tac m * n] | ||
theorem Int.pos_mul_pos_is_pos_disj (n m : Int) : m < 0 ∨ n < 0 ∨ 0 ≤ m * n := by | ||
cases h: (m < 0 : Bool) <;> simp_all | ||
cases h: (n < 0 : Bool) <;> simp_all | ||
right; right; apply pos_mul_pos_is_pos <;> tauto | ||
|
||
-- Some tests | ||
section | ||
|
||
-- Activate the rule set for non linear arithmetic | ||
set_option scalarTac.nonLin true | ||
|
||
example (x y : Int) (h : 0 ≤ x ∧ 0 ≤ y) : 0 ≤ x * y := by scalar_tac | ||
|
||
end |
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
Oops, something went wrong.