-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dependent forall propagator in
grind
(#6498)
This PR adds support in the `grind` tactic for propagating dependent forall terms `forall (h : p), q[h]` where `p` is a proposition.
- Loading branch information
1 parent
82bae24
commit f7c4edc
Showing
6 changed files
with
55 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
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 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Leonardo de Moura | ||
-/ | ||
prelude | ||
import Init.Grind.Lemmas | ||
import Lean.Meta.Tactic.Grind.Types | ||
import Lean.Meta.Tactic.Grind.Internalize | ||
import Lean.Meta.Tactic.Grind.Simp | ||
|
||
namespace Lean.Meta.Grind | ||
/-- | ||
If `parent` is a projection-application `proj_i c`, | ||
check whether the root of the equivalence class containing `c` is a constructor-application `ctor ... a_i ...`. | ||
If so, internalize the term `proj_i (ctor ... a_i ...)` and add the equality `proj_i (ctor ... a_i ...) = a_i`. | ||
-/ | ||
def propagateForallProp (parent : Expr) : GoalM Unit := do | ||
let .forallE n p q bi := parent | return () | ||
unless (← isEqTrue p) do return () | ||
let h₁ ← mkEqTrueProof p | ||
let qh₁ := q.instantiate1 (mkApp2 (mkConst ``of_eq_true) p h₁) | ||
let r ← pre qh₁ | ||
let q := mkLambda n bi p q | ||
let q' := r.expr | ||
internalize q' (← getGeneration parent) | ||
let h₂ ← r.getProof | ||
let h := mkApp5 (mkConst ``Lean.Grind.forall_propagator) p q q' h₁ h₂ | ||
pushEq parent q' h | ||
|
||
end Lean.Meta.Grind |
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
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,6 @@ | ||
opaque f (a : Array Bool) (i : Nat) (h : i < a.size) : Bool | ||
|
||
set_option trace.grind.eqc true | ||
|
||
example : (p ∨ ∀ h : i < a.size, f a i h) → (hb : i < b.size) → a = b → ¬p → f b i hb := by | ||
grind |