-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a solver backend for lean-auto. (#150)
* Provide a solver backend for lean-auto. * Add lean-auto lake configs. * Reorder dependencies.
- Loading branch information
Showing
6 changed files
with
99 additions
and
2 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,36 @@ | ||
/- | ||
Copyright (c) 2021-2024 by the authors listed in the file AUTHORS and their | ||
institutional affiliations. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Abdalrhman Mohamed | ||
-/ | ||
|
||
import Auto.Tactic | ||
import Smt.Tactic.Smt | ||
|
||
open Lean in | ||
def smtSolverFunc (ls : Array Auto.Lemma) (is : Array Auto.Lemma) : MetaM Expr := do | ||
let fi l := do | ||
let userName ← mkFreshUserName `inst | ||
let type ← Meta.mkAppM ``Inhabited #[l.type] | ||
let value ← Meta.mkAppOptM ``Inhabited.mk #[l.type, l.proof] | ||
return { userName, type, value } | ||
let is ← is.mapM fi | ||
let fl l := do | ||
let userName ← mkFreshUserName `h | ||
let type ← Auto.Lam2D.approxSimpNF l.type | ||
let value := l.proof | ||
return { userName, type, value } | ||
let ls ← ls.mapM fl | ||
let h ← Meta.mkFreshExprMVar (Expr.const ``False []) | ||
let (_, mv) ← h.mvarId!.assertHypotheses is | ||
let (fvs, mv) ← mv.assertHypotheses ls | ||
mv.withContext do | ||
let hs := fvs.map (.fvar ·) | ||
_ ← Smt.smt mv hs.toList | ||
-- Note: auto should allow solvers to export new goals to users | ||
-- for mv in mvs do | ||
-- logInfo m!"new : {mv}" | ||
instantiateMVars h | ||
|
||
attribute [rebind Auto.Native.solverFunc] smtSolverFunc |
Empty file.
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,48 @@ | ||
import Mathlib.Algebra.Group.Defs | ||
import Mathlib.Data.Set.Function | ||
|
||
import Smt | ||
import Smt.Auto | ||
|
||
set_option auto.native true | ||
|
||
example {α : Type} (x : α) : List.head? [x] = .some x := by | ||
have h₂ : ∀ (x : α) (ys : _), List.head? (x :: ys) = .some x := fun _ _ => rfl | ||
auto | ||
|
||
example {α : Type} (x y : α) : [x] ++ [y] = [x, y] := by | ||
-- Invoke definition unfolding | ||
have h : ∀ (x y : List α), x ++ y = x.append y := fun _ _ => rfl | ||
auto [h] d[List.append] | ||
|
||
variable {G : Type} [Group G] | ||
|
||
theorem inverse' : ∀ (a : G), a * a⁻¹ = 1 := by | ||
auto [mul_assoc, one_mul, inv_mul_cancel] | ||
|
||
theorem identity' : ∀ (a : G), a * 1 = a := by | ||
auto [mul_assoc, one_mul, inv_mul_cancel, inverse'] | ||
|
||
theorem unique_identity (e : G) : (∀ z, e * z = z) → e = 1 := by | ||
auto [mul_assoc, one_mul, inv_mul_cancel] | ||
|
||
-- TODO: pre-process Nat away | ||
-- example {α : Type} (x y : α) : List.get? [x, y] 1 = .some y := by | ||
-- auto d[List.get?] | ||
|
||
set_option auto.mono.mode "fol" | ||
|
||
variable {α β : Type} [Nonempty α] [Nonempty β] {f : α → β} {s : Set α} {v u : Set β} | ||
|
||
example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := by | ||
auto [Set.subset_def, Set.mem_image, Set.mem_preimage] | ||
|
||
example (h : Function.Injective f) : f ⁻¹' (f '' s) ⊆ s := by | ||
auto [Set.subset_def, Set.mem_preimage, Function.Injective.mem_set_image, h] | ||
|
||
example : f '' (f ⁻¹' u) ⊆ u := by | ||
auto [Set.subset_def, Set.mem_image, Set.mem_preimage] | ||
|
||
example (h : Function.Surjective f) : u ⊆ f '' (f ⁻¹' u) := by | ||
unfold Function.Surjective at h | ||
auto [Set.subset_def, Set.mem_image, Set.mem_preimage, h] |
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