Skip to content

Commit

Permalink
Updated to lean v4.4.0-rc1 but temporarily removed bitvector function…
Browse files Browse the repository at this point in the history
…ality
  • Loading branch information
JOSHCLUNE committed Dec 19, 2023
1 parent c42a690 commit b2db928
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 27 deletions.
15 changes: 12 additions & 3 deletions Auto/Embedding/LamChecker.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import Auto.Embedding.LamConv
import Auto.Embedding.LamInference
import Auto.Embedding.LamLCtx
import Auto.Embedding.LamPrep
import Auto.Embedding.LamBitVec
-- Temporarily removing this input until I can get this file to build on Lean v4.4.0-rc1
-- import Auto.Embedding.BitVec
import Auto.Embedding.LamInductive
import Auto.Lib.BinTree
open Lean
Expand Down Expand Up @@ -601,8 +602,10 @@ inductive PrepConvStep where
| validOfPropEq : PrepConvStep
/-- (a = b) ↔ (a ∨ b) ∧ (¬ a ∨ ¬ b) -/
| validOfPropNe : PrepConvStep
/- Temporarily removing this operation until I can get Auto.Embedding.BitVec to build on Lean v4.4.0-rc1
/-- Basic BitVec simplification operations -/
| validOfPushBVCast : PrepConvStep
-/
deriving Inhabited, Hashable, BEq, Lean.ToExpr

inductive WFStep where
Expand Down Expand Up @@ -703,7 +706,9 @@ def PrepConvStep.toString : PrepConvStep → String
| .validOfNotImpEquivAndNot => s!"validOfNotImpEquivAndNot"
| .validOfPropEq => s!"validOfPropEq"
| .validOfPropNe => s!"validOfPropNe"
/- Temporarily removing this operation until I can get Auto.Embedding.BitVec to build on Lean v4.4.0-rc1
| .validOfPushBVCast => s!"validOfPushBVCast"
-/

def WFStep.toString : WFStep → String
| .wfOfCheck lctx t => s!"wfOfCheck {lctx} {t}"
Expand Down Expand Up @@ -1145,7 +1150,9 @@ def InferenceStep.evalValidOfBVarLowers (r : RTable) (lctx : List LamSort) (pns
| .validOfNotImpEquivAndNot => LamTerm.not_imp_equiv_and_not?
| .validOfPropEq => LamTerm.propeq?
| .validOfPropNe => LamTerm.propne?
/- Temporarily removing this operation until I can get Auto.Embedding.BitVec to build on Lean v4.4.0-rc1
| .validOfPushBVCast => fun t => LamTerm.pushBVCast .none t
-/

@[reducible] def WFStep.eval (lvt lit : Nat → LamSort) (r : RTable) : (cs : WFStep) → EvalResult
| .wfOfCheck lctx t =>
Expand Down Expand Up @@ -2110,9 +2117,11 @@ theorem PrepConvStep.eval_correct (lval : LamValuation) :
| .validOfPropNe => And.intro
LamGenConv.propne?
(LamTerm.evarBounded_of_evarEquiv @LamTerm.maxEVarSucc_propne?)
/- Temporarily removing this operation until I can get Auto.Embedding.BitVec to build on Lean v4.4.0-rc1
| .validOfPushBVCast => And.intro
LamGenConv.pushBVCast
(LamTerm.evarBounded_of_evarEquiv LamTerm.evarEquiv_pushBVCast)
-/

theorem WFStep.eval_correct
(r : RTable) (cv : CVal.{u} r.lamEVarTy) (inv : r.inv cv) :
Expand Down Expand Up @@ -2320,12 +2329,12 @@ theorem Checker.getValidExport_indirectReduceAux
LamThmValid cpv.toLamValuationEraseEtom lctx t := by
apply RTable.getValidExport_correct _ heq
have lvtEq : (fun n => (lvt.get? n).getD (.base .prop)) = cpv.toLamVarTy := by
cases cpv; dsimp [CPVal.toLamVarTy]; apply funext; intro n
cases cpv; unfold CPVal.toLamVarTy; apply funext; intro n
rw [← Option.getD_map (f:=@Sigma.fst LamSort _)]; dsimp
apply congrFun; apply congrArg; rw [hlvt, BinTree.get?_mapOpt]
apply Eq.symm; apply Option.map_eq_bind
have litEq : (fun n => (lit.get? n).getD (.base .prop)) = cpv.toLamILTy := by
cases cpv; dsimp [CPVal.toLamILTy]; apply funext; intro n
cases cpv; unfold CPVal.toLamILTy; apply funext; intro n
rw [← Option.getD_map (f:=@Sigma.fst LamSort _)]; dsimp
apply congrFun; apply congrArg; rw [hlit, BinTree.get?_mapOpt]
apply Eq.symm; apply Option.map_eq_bind
Expand Down
4 changes: 2 additions & 2 deletions Auto/Embedding/LamConv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ def LamTerm.mpAll? (rw : LamTerm) (t : LamTerm) : Option LamTerm :=
| _ => .none

theorem LamTerm.evarBounded_mpAll? : evarBounded (LamTerm.mpAll? rw) rw.maxEVarSucc := by
dsimp [LamTerm.mpAll?]
unfold LamTerm.mpAll?
cases rw <;> try dsimp <;> try apply evarBounded_none
case app s fn rhs =>
cases fn <;> try dsimp <;> try apply evarBounded_none
Expand All @@ -1621,7 +1621,7 @@ theorem LamTerm.evarBounded_mpAll? : evarBounded (LamTerm.mpAll? rw) rw.maxEVarS

theorem LamGenConv.mpAll?
(hvalid : LamThmValid lval [] rw) : LamGenConv lval (LamTerm.mpAll? rw) := by
dsimp [LamTerm.mpAll?]
unfold LamTerm.mpAll?
cases rw <;> try dsimp <;> try apply LamGenConv.none
case app s fn rhs =>
cases fn <;> try dsimp <;> try apply LamGenConv.none
Expand Down
1 change: 0 additions & 1 deletion Auto/Embedding/LamSystem.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,6 @@ theorem LamGenModify.rwGenAtIfSign {modify} (H : LamGenModify lval modify weaken
induction l generalizing occ weaken? weaken?'
case zero =>
cases List.length_eq_zero.mp (Nat.le_zero.mp hl)
dsimp [LamTerm.rwGenAtIfSign, LamTerm.isSign]
match h : weaken? == weaken?' with
| true => cases (Bool.beq_to_eq _ _).mp h; exact H
| false => dsimp [LamGenModify]; intro t₁ t₂ h; cases h
Expand Down
2 changes: 1 addition & 1 deletion Auto/Lib/BinTree.lean
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ theorem allp'_node (p : α → Prop) :
have h' := h (2 * n + 5)
rw [get?'_succSucc] at h'
have eq₁ : (2 * n + 5) % 2 = 1 := by
rw [Nat.add_mod]; simp
rw [Nat.add_mod]; simp; rfl
have eq₂ : (2 * n + 5) / 2 = n + 2 := by
rw [Nat.add_comm _ 5];
rw [Nat.add_mul_div_left];
Expand Down
4 changes: 2 additions & 2 deletions Auto/Lib/NatExtra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ theorem Nat.max_add {a b c : Nat} : max a b + c = max (a + c) (b + c) := by
simp [h, naleb]

theorem Nat.max_lt {a b c : Nat} : max a b < c ↔ a < c ∧ b < c := by
rw [← Nat.lt_eq]; dsimp [Nat.lt]; rw [← Nat.add_one]; rw [Nat.max_add]
rw [Nat.max_le]; apply Iff.intro id id
rw [← Nat.lt_eq, Nat.lt]; dsimp only [Nat.le_eq]; rw [← Nat.add_one];
rw [Nat.max_add]; rw [Nat.max_le]; apply Iff.intro id id

theorem Nat.max_zero_left {a : Nat} : max 0 a = a := by
rw [Nat.max_def]; simp
Expand Down
6 changes: 3 additions & 3 deletions Auto/Lib/Pos.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ theorem toNat'_not_zero (p : Pos) : toNat' p ≠ 0 := by
case inl H' => revert H'; exact IH
case inr H' => cases H'
case xI p' _ =>
simp [toNat']
simp [toNat']

private theorem ofNat'WFAux (n n' : Nat) : n = n' + 2 → n / 2 < n := by
intro H; apply Nat.div_lt_self
Expand Down Expand Up @@ -96,7 +96,7 @@ theorem ofNat'WF.doubleSucc_xI (n : Nat) :
rw [ofNat'WF.succSucc];
have heq : (2 * n' + 3 + 2) % 2 = 1 := by
rw [Nat.add_mod_right]; rw [Nat.add_mod]
rw [Nat.mul_mod]; simp
rw [Nat.mul_mod]; simp; rfl
rw [heq]; simp
have heq' : Nat.succ ((2 * n' + 3) / 2) = n' + 2 := by
apply congrArg; rw [Nat.add_comm];
Expand Down Expand Up @@ -297,4 +297,4 @@ theorem succ_inj (p q : Pos) : succ p = succ q → p = q := fun H =>

end Pos

end Auto
end Auto
2 changes: 2 additions & 0 deletions Auto/Translation/LamReif.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,9 @@ section CheckerUtils
else
return (vs, minds))
let vs ← vs.mapM validOfBetaReduce
/- Temporarily removing this operation until I can get Auto.Embedding.BitVec to build on Lean v4.4.0-rc1
let vs ← vs.mapM (fun re => validOfPrepConv .validOfPushBVCast re [])
-/
let vs ← vs.mapM validOfRevertAll
for v in vs do
trace[auto.lamReif.prep.printResult] "{v}"
Expand Down
24 changes: 13 additions & 11 deletions lake-manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{"version": 6,
"packagesDir": "lake-packages",
{"version": 7,
"packagesDir": ".lake/packages",
"packages":
[{"git":
{"url": "https://github.com/leanprover/std4.git",
"subDir?": null,
"rev": "9bfbd2a12ee9cf2e159a8a6b4d1ef6c149728f66",
"opts": {},
"name": "std",
"inputRev?": "main",
"inherited": false}}],
"name": "auto"}
[{"url": "https://github.com/leanprover/std4.git",
"type": "git",
"subDir": null,
"rev": "9e37a01f8590f81ace095b56710db694b5bf8ca0",
"name": "std",
"manifestFile": "lake-manifest.json",
"inputRev": "9e37a01f8590f81ace095b56710db694b5bf8ca0",
"inherited": false,
"configFile": "lakefile.lean"}],
"name": "auto",
"lakeDir": ".lake"}
5 changes: 2 additions & 3 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import Lake
open Lake DSL

package «auto» {
precompileModules := true
preferReleaseBuild := true
-- add any package configuration options here
}

require std from git
"https://github.com/leanprover/std4.git"@"main"
"https://github.com/leanprover/std4.git"@"9e37a01f8590f81ace095b56710db694b5bf8ca0"

@[default_target]
lean_lib «Auto» {
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.3.0-rc1
leanprover/lean4:v4.4.0-rc1

0 comments on commit b2db928

Please sign in to comment.