Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
46a0789
Start implementing iinduction: move IntoIH from Induction.lean to Cla…
alvinylt May 26, 2026
5421a78
Simple iinduction test
alvinylt May 28, 2026
562fd64
Use evalTacticAt for iinduction
alvinylt May 28, 2026
9af4f6f
Try using iRevertCore and iIntroCore separately
alvinylt May 28, 2026
72fd7a0
Finish the proof for iinduction
alvinylt May 28, 2026
a7aeae1
Use iRevertIntro instead of iRevertCore and iIntroCore separately
alvinylt May 28, 2026
6203c5f
Remove redundant Iris entailment in Lean context
alvinylt May 28, 2026
7035695
Avoid unnamed variable in generated induction subgoals
alvinylt May 28, 2026
e963f76
Revert all hypotheses in the intuitionistic context
alvinylt May 28, 2026
d9fa30a
Towards using IntoIH for moving induction hypothesis from Lean's cont…
alvinylt May 28, 2026
ffcdbb3
Revert only spatial and intuitionistic hypotheses that contain x
alvinylt May 29, 2026
e94141b
Use the result of IntoIH synthesis in addIntoIH
alvinylt May 29, 2026
8ba460a
Iteratively add induction hypotheses into the Iris proof state
alvinylt May 29, 2026
8524a82
Towards implementing findIHs
alvinylt May 29, 2026
998ffb8
Implement findIHs
alvinylt May 29, 2026
4bc644c
Remove induction hypotheses from the regular Lean context
alvinylt May 29, 2026
4f6817a
Adjust iHypsContaining
alvinylt May 29, 2026
ff5ea5c
Introducing IHs into the Iris intuitionstic context
alvinylt May 29, 2026
2f47ceb
Use Lean.Meta.Tactic.induction instead of evalTacticAt for more flexi…
alvinylt May 30, 2026
a9be948
Generalisation to find recursor name for induction
alvinylt May 30, 2026
c627c24
Towards having explicit variable names for induction hypotheses
alvinylt May 30, 2026
a11f967
Solve kernel mismatch, currently using a placeholder theorem
alvinylt May 30, 2026
b304c88
Implement InductionState, towards finishing the placeholder theorem
alvinylt May 30, 2026
7395139
Finish revert_IH proof, more assumptions required
alvinylt May 30, 2026
cbdadb6
Towards completing the use of InductionState
alvinylt May 30, 2026
5a5beaa
Port type class instances into_ih_Forall and into_ih_Forall2
alvinylt May 30, 2026
aa5f430
Finish proof for intoIH_listForall
alvinylt May 30, 2026
eab9ccf
Finish proof for intoIH_listForall2
alvinylt May 30, 2026
b6b03a1
Code refactoring and comments
alvinylt May 30, 2026
783ad43
Remove goal from InductionState, simplifications
alvinylt May 30, 2026
31e5633
Add test for iinduction
alvinylt May 31, 2026
bfd3e59
Obtain constructor names from inductInfo: towards allowing user-given…
alvinylt May 31, 2026
e5c7a22
Towards implementing the `with` syntax
alvinylt May 31, 2026
7d1cb7c
Pretty variables for cases in the `with` syntax
alvinylt May 31, 2026
b826e7f
Check for invalid alternative names and throw pretty error
alvinylt May 31, 2026
43b8215
Move most of elaboration code into iInductionCore for reusability
alvinylt May 31, 2026
48945d9
iInductionCore: alternative names being optional, use pattern matching
alvinylt May 31, 2026
7378f8d
Code refactoring
alvinylt May 31, 2026
3632223
More code refactoring
alvinylt May 31, 2026
1dbd7ac
More code refactoring 2 and fix tests
alvinylt May 31, 2026
e376e70
More code refactoring and formatting
alvinylt May 31, 2026
bff359b
Implement iinduction ... using ... (user-supplied recursor name)
alvinylt Jun 1, 2026
e87b607
Implement iinduction ... using ... with
alvinylt Jun 1, 2026
a8daced
Implement iinduction ... generalizing ...
alvinylt Jun 1, 2026
ab75206
Fix iinduction ... generalizing ...
alvinylt Jun 1, 2026
34fece6
Use binderIdent instead of ident for `with` syntax to support undersc…
alvinylt Jun 1, 2026
cc81368
Catch invalid, missing and duplicate constructor names when `with` sy…
alvinylt Jun 1, 2026
1525cd2
Hypotheses explicitly reverted by the user using the `generalized` sy…
alvinylt Jun 1, 2026
559ba5a
Consolidate tests for iinduction
alvinylt Jun 1, 2026
10589a5
Define new function isIrisGoalWithForalls for findIHs: search for Iri…
alvinylt Jun 1, 2026
58efe2c
Fix priority of IntoIH instances
alvinylt Jun 1, 2026
062ec01
More iinduction tests
alvinylt Jun 1, 2026
9a17cba
Generalisation to provide support for expressions, not just idents
alvinylt Jun 1, 2026
18a9e31
Code formatting
alvinylt Jun 1, 2026
c95dede
Catch extra arguments for alternative names
alvinylt Jun 2, 2026
bd0fca7
Fallback recursor name when getCustomEliminator? fails
alvinylt Jun 2, 2026
76f321b
The constructor names should depend on the recursor
alvinylt Jun 2, 2026
9831208
Remove redundant comment
alvinylt Jun 2, 2026
7709bbf
Add test with binary tree
alvinylt Jun 2, 2026
e0c690a
Bug fix for handling more than one IH in addIH, simplify InductionSta…
alvinylt Jun 2, 2026
7b893ca
Pretty goal naming with clickable drop-down in InfoView
alvinylt Jun 2, 2026
4d51583
Improve findIHs comment and remove redundant function isIrisGoalWithF…
alvinylt Jun 3, 2026
5570273
Add more specific error message for IntoIH synthesis failure in addIH
alvinylt Jun 3, 2026
05b2cb9
Refactor buildPfIntHyps as Hyps.buildIntuitionisticProof
alvinylt Jun 3, 2026
2abdf66
Remove unused function: Hyps.intuitionisticProps
alvinylt Jun 3, 2026
8412da6
Rename iHypsContaining to iHypsToGeneralize, refine docstring
alvinylt Jun 3, 2026
73e28b6
Move addIH into addIHs inline
alvinylt Jun 3, 2026
97f0ef7
Improve revert_IH docstring explanation
alvinylt Jun 4, 2026
d7d9da5
Rename termToFVar as generalizeTermWithFVar, more details in the comment
alvinylt Jun 4, 2026
343af53
Generalise ProofModeContinuation, towards avoiding directly manipulat…
alvinylt Jun 4, 2026
258aad6
Rename inductionAlts as inductionAlt for consistency with Lean.Init.T…
alvinylt Jun 5, 2026
ff898f6
Consolidate elaborations into one, move comment from text to elaborat…
alvinylt Jun 5, 2026
b22135d
Further generalise iRevertIntro, update usage of continuation function
alvinylt Jun 5, 2026
fec0ee0
Move code that manipulates ProofModeM to ProofModeM.lean
alvinylt Jun 6, 2026
95c53c2
Simplify the handling of user-supplied tactics in iInductionCore
alvinylt Jun 6, 2026
d64a101
Eliminate custom-defined inductionAlt, reuse built-in definition instead
alvinylt Jun 6, 2026
4f2d10b
Define structures for better code organisation
alvinylt Jun 6, 2026
6b43be8
Implement tactic before alts
alvinylt Jun 6, 2026
32bb9fb
Typo fix
alvinylt Jun 6, 2026
43562d1
Allowing multiple constructors for the same set of tactic sequences
alvinylt Jun 6, 2026
d7408bb
Simplify parsing
alvinylt Jun 6, 2026
024b975
Debug: remove incorrect popping of goal from ProofModeM state
alvinylt Jun 6, 2026
b0bd59f
Implement hole and synthetic hole on RHS of `=>` using `with` syntax
alvinylt Jun 6, 2026
a333ac3
Use short syntax name
alvinylt Jun 6, 2026
cf43a44
Improve pattern matching in parser
alvinylt Jun 6, 2026
4def6f0
Simplify imports
alvinylt Jun 6, 2026
c53d592
Towards supporting wildcard
alvinylt Jun 6, 2026
a023c04
Implement wildcard as last alternative
alvinylt Jun 6, 2026
931eabb
More syntax tests
alvinylt Jun 6, 2026
8f19e97
Check for redundant wildcard alternative
alvinylt Jun 6, 2026
f2fb850
More tests for wildcard syntax
alvinylt Jun 6, 2026
0127a9f
Minor refinements
alvinylt Jun 6, 2026
afccd6c
Check for redundant alternative names after the first tactic
alvinylt Jun 6, 2026
812b3eb
Error handling without explicit checks with a function
alvinylt Jun 6, 2026
5b32861
Error message refinements
alvinylt Jun 6, 2026
d39bce3
Minor refinements
alvinylt Jun 7, 2026
0731db4
Implement checkDependentHyps and refactor the way targets for iRevert…
alvinylt Jun 7, 2026
3a2f03c
Towards pretty suggestions
alvinylt Jun 7, 2026
e568514
Fix spacing in pretty TryThis suggestion using ppSpace, adjust order …
alvinylt Jun 7, 2026
269d7b6
Fix missing introduction subgoal introduction when `with` syntax is n…
alvinylt Jun 7, 2026
febf3f2
Bug fix: withoutFVars should wrap over addBIGoal
alvinylt Jun 7, 2026
196450a
Minor formatting issue
alvinylt Jun 7, 2026
4b85ced
Minor refinements: tactic explanation
alvinylt Jun 7, 2026
675be7c
Merge remote-tracking branch 'upstream' into iInduction
alvinylt Jun 14, 2026
5d00ede
Update intuitionistically_sep_2 as intuitionistically_sep_mpr in Expr…
alvinylt Jun 14, 2026
8c29bed
Update sep_mono_l and sep_mono_r as sep_mono_left and sep_mono_right …
alvinylt Jun 14, 2026
17aefd6
iinduction usage: wp_makeList in HeapLang/Lib/Quicksort.lean
alvinylt Jun 14, 2026
f1f0263
iinduction usage: Instances/Lib/FUpd.lean
alvinylt Jun 14, 2026
2d26cef
iinduction usage: wp_pure_step_fupd in ProgramLogic/Lifting.lean
alvinylt Jun 14, 2026
bf2fbe2
Simplify alternative name comparison
alvinylt Jun 15, 2026
02678a2
Minor refinements: tests for error messages and alternative names
alvinylt Jun 15, 2026
ae4fd2d
Tests with binary tree
alvinylt Jun 15, 2026
a5fcc55
Tests with natural numbers and lists
alvinylt Jun 15, 2026
7714f79
Consolidate iinduction tests
alvinylt Jun 15, 2026
5782aee
More consolidation of iinduction tests
alvinylt Jun 15, 2026
b71df06
More consolidation of iinduction tests: `generalize` syntax
alvinylt Jun 15, 2026
5f81ec0
Minor comment fix
alvinylt Jun 15, 2026
107e19d
Another test with Tree.mirror
alvinylt Jun 15, 2026
57ecb81
Test iinduction for pure hypotheses and spatial hypotheses
alvinylt Jun 15, 2026
9ba7098
irevert bug fix
alvinylt Jun 15, 2026
341e827
Fix missing Iris hypotheses in "Try this" suggestion
alvinylt Jun 15, 2026
dcd1206
Ensure the "Try this" suggestion handles order of hypotheses in `gene…
alvinylt Jun 15, 2026
38090e0
Typo fix
alvinylt Jun 15, 2026
ae2dc76
Implement "Try this" suggestion for iloeb and irevert
alvinylt Jun 15, 2026
ab12f97
Adjust the priority of IntoIH type class instances
alvinylt Jun 15, 2026
78c7e28
Tests with NTree for `List.Forall₂`
alvinylt Jun 15, 2026
1386255
Define containsIrisGoal to recursive traverse an expression to see if…
alvinylt Jun 15, 2026
23b6d27
Complete proof example that uses `iinduction` with `intoIH_listForall₂`
alvinylt Jun 15, 2026
f21db0a
Remove unused definitions in tests
alvinylt Jun 15, 2026
53d1c3d
Rewrite comment for checkDependentHyps
alvinylt Jun 15, 2026
c684029
Remove intoIH_listForall
alvinylt Jun 16, 2026
f66b5ce
Merge remote-tracking branch 'origin/master' into iInduction
MackieLoeffel Jun 16, 2026
d2dfc2f
Add proof for testing `iinduction` with `NTree.induction_principle`
alvinylt Jun 17, 2026
0724695
Check for forward dependencies in `iHypsToGeneralize`
alvinylt Jun 17, 2026
4d9d5a1
Avoid repetitive code for `checkDependentHyps`
alvinylt Jun 17, 2026
2721180
Refactor code in `iInductionCore`
alvinylt Jun 17, 2026
65b92b3
Minor refactoring
alvinylt Jun 17, 2026
3bd9128
Factorise the continuation function within `iInductionCore`
alvinylt Jun 17, 2026
2cbe8ef
Use `Option.forM` to avoid unnecessary no-ops
alvinylt Jun 17, 2026
9c4fc02
Use `Std.HashSet` in `checkCtors` for efficient check for duplicates …
alvinylt Jun 17, 2026
3c4e87a
Condense comments and syntax formatting
alvinylt Jun 17, 2026
8f71934
Minor formatting
alvinylt Jun 17, 2026
bee1c3c
Minor fix
alvinylt Jun 17, 2026
1c98244
Merge remote-tracking branch 'upstream' into iInduction
alvinylt Jun 18, 2026
2c57b4a
Update `intoIH_entails` in response to #469
alvinylt Jun 19, 2026
0a6fd19
Eliminate unnecessary use of `Option` for `genSelTargets` in `iInduct…
alvinylt Jun 19, 2026
40141f3
Rename `k` as `kIntro`, use `k'` inline to avoid variable declaration
alvinylt Jun 19, 2026
7df0c36
Minor comment improvements
alvinylt Jun 19, 2026
2cbd1ad
Refactor `addBIGoalRunTactics`
alvinylt Jun 19, 2026
50ee146
Towards a one-liner `findIHs`
alvinylt Jun 19, 2026
7afbc84
Move `findIHs` inline and further condensation
alvinylt Jun 19, 2026
2943d7a
Further condense `ihFVars`
alvinylt Jun 19, 2026
572f50a
Minor simplifications regarding monadic operations
alvinylt Jun 19, 2026
fc2239a
Minor simplifications
alvinylt Jun 19, 2026
89a8226
Eliminate `containsIrisGoal` by moving it inline
alvinylt Jun 19, 2026
e54087d
Always require manual resolution of hypotheses dependent on the induc…
alvinylt Jun 19, 2026
93d8585
Update comments
alvinylt Jun 19, 2026
d4073c4
Typo fix
alvinylt Jun 19, 2026
27d03eb
Refactor code in `Revert.lean`: introduce `getDependentHyps`
alvinylt Jun 20, 2026
c73bcbb
New function `getCompleteSelTargets` for the fixed selection targets
alvinylt Jun 20, 2026
5337208
Implement `generalizing!` syntax: implicit reverting
alvinylt Jun 20, 2026
6ca077e
Minor formatting
alvinylt Jun 20, 2026
7aa10c2
Test `generalizing!` syntax
alvinylt Jun 20, 2026
9603821
Print "Try this" suggestion only when all names are accessible
alvinylt Jun 20, 2026
bbaa9ac
Print second "Try this" suggestion
alvinylt Jun 20, 2026
697ddf4
Implement `generalizing!` for `iloeb`
alvinylt Jun 20, 2026
aa7060c
Towards better error printing with inaccessible names
alvinylt Jun 20, 2026
869d8e3
Implement `irevert!` as an alternative to `irevert` for auto-resoluti…
alvinylt Jun 20, 2026
7f053e1
Bug fix: spatial hypotheses should also be checked for `irevert`
alvinylt Jun 20, 2026
07a1c6b
Handle the printing of inaccessible names properly
alvinylt Jun 20, 2026
7460200
Update tests
alvinylt Jun 20, 2026
c69fac3
Minor bug fix
alvinylt Jun 20, 2026
bffe809
Code formatting 1
alvinylt Jun 20, 2026
bc5684d
Code formatting 2
alvinylt Jun 20, 2026
ff45f2b
Code formatting 3
alvinylt Jun 20, 2026
aabdbe2
Reduce code repetition with `iLoebCore`
alvinylt Jun 20, 2026
11d0baa
Update `ProofMode/Porting.lean`
alvinylt Jun 20, 2026
0ae8fb3
Update `tactics.md`
alvinylt Jun 20, 2026
c3ff1e7
Typo fix
alvinylt Jun 20, 2026
77335b6
More accurate descriptions in `tactics.md`
alvinylt Jun 20, 2026
e91f09e
Add a test for `irevert!`
alvinylt Jun 26, 2026
348b093
Add a test for `iloeb` with `generalizing!` clause
alvinylt Jun 26, 2026
462d2d3
Minor formatting
alvinylt Jun 26, 2026
d8dc168
Merge remote-tracking branch 'upstream/master' into iInduction
alvinylt Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Iris/Iris/HeapLang/Lib/Quicksort.lean
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,12 @@ theorem quicksort_spec l ls Φ :
theorem wp_makeList (l : List Int) (Φ : Val → IProp GF) :
(∀ v, isList v l -∗ Φ v) -∗
WP hl(&(makeList l)) {{ Φ }} := by
induction l generalizing Φ with
iintro HΦ
iinduction l generalizing %Φ HΦ with
| nil =>
iintro HΦ
unfold makeList
iapply nil_spec $$ HΦ
| cons l ls ih =>
iintro HΦ
rw [makeList]
wp_pures
wp_bind &(makeList _)
Expand Down
22 changes: 10 additions & 12 deletions Iris/Iris/Instances/Lib/FUpd.lean
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,26 @@ theorem lc_fupd_add_later {E1 E2 : CoPset} {P : IProp GF} : ⊢ £ 1 -∗ (▷ |
@[rocq_alias lc_fupd_add_laterN]
theorem lc_fupd_add_laterN (n : Nat) {E : CoPset} {P : IProp GF} :
⊢ £ n -∗ (▷^[n] |={E}=> P) -∗ |={E}=> P := by
induction n generalizing P with
iintro Hf Hupd
iinduction n with
| zero =>
iintro _ H
simp [BIBase.laterN]
iexact H
iexact Hupd
| succ n IH =>
iintro Hf Hupd
icases Hf with ⟨H1, Hf⟩
iapply lc_fupd_add_later $$ H1
inext
iapply IH $$ [$] [$]

@[rocq_alias lc_fupd_add_step_fupdN ]
@[rocq_alias lc_fupd_add_step_fupdN]
theorem lc_fupd_add_step_fupdN (E1 E2 E3: CoPset) (P : IProp GF) (n : Nat) :
£ n -∗ (|={E1}[E2]▷=>^[n] |={E1,E3}=> P) -∗ |={E1,E3}=> P := by
induction n generalizing P with
£ n -∗ (|={E1}[E2]▷=>^[n] |={E1,E3}=> P) -∗ |={E1,E3}=> P := by
iintro Hf Hupd
iinduction n with
| zero =>
iintro _ H
simp only [Nat.repeat]
iexact H
iexact Hupd
| succ n IH =>
iintro Hf Hupd
simp only [Nat.repeat]
imod Hupd
icases Hf with ⟨H1, Hf⟩
Expand Down Expand Up @@ -404,12 +402,12 @@ instance elimModal_fupd_fupd_finally p (E1 E2 : CoPset) (P Q : IProp GF) :
@[rocq_alias step_fupdN_fupd_finally]
theorem step_fupdN_fupd_finally (E1 E2 : CoPset) (n : Nat) (P : IProp GF) :
(|={E1}[E2]▷=>^[n] |={E1|}=> P) ⊢ |={E1|}=> ▷^[n] ◇ P := by
induction n with
iintro HP
iinduction n with
| zero =>
simp only [Nat.repeat]
exact fupd_finally_mono except0_intro
| succ n IH =>
iintro HP
simp only [Nat.repeat]
imod HP
iapply fupd_finally_mono (later_laterN n).mpr
Expand Down
4 changes: 1 addition & 3 deletions Iris/Iris/ProgramLogic/Lifting.lean
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ theorem wp_pure_step_fupd [Inhabited State] (E₂ : CoPset)
[Hexec : PureExec φ n e₁ e₂] (Hφ : φ) :
(|={E}[E₂]▷=>^[n] £ n -∗ WP e₂ @ s; E {{ Φ }}) ⊢ WP e₁ @ s; E {{ Φ }} := by
replace Hexec := Hexec.pureExec Hφ
induction Hexec using Relation.Iterate.head_induction_on with
iinduction Hexec using Relation.Iterate.head_induction_on with simp only [Nat.repeat]
| rfl =>
iintro Hwp
simp only [Nat.repeat]
rw (occs := [2]) [fupd_wp_iff.to_eq]
icases lc_zero with >Hz
iapply Hwp $$ Hz
Expand All @@ -202,7 +201,6 @@ theorem wp_pure_step_fupd [Inhabited State] (E₂ : CoPset)
intro σ
have _ : PrimStep.Reducible (e₁, σ) := by grind only [reducible_of_reducibleNoObs]
grind [cases Stuckness]
simp only [Nat.repeat]
iapply step_fupd_wand $$ Hwp
iintro Hwp Hone
iapply IH
Expand Down
11 changes: 10 additions & 1 deletion Iris/Iris/ProofMode/Classes.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2022 Lars König. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Lars König, Michael Sammler, Alvin Tang
Authors: Lars König, Michael Sammler, Yunsong Yang, Alvin Tang
-/
module

Expand Down Expand Up @@ -224,6 +224,15 @@ class CombineSepGives [BI PROP] (P Q : PROP) (R : outParam PROP) where
combine_sep_gives : P ∗ Q ⊢ <pers> R
export CombineSepGives (combine_sep_gives)

/-
`IntoIH φ P Q` describes how to turn a pure induction hypothesis `φ` into a proofmode
hypothesis `Q` under an intuitionistic BI context `□ P`.
-/
@[ipm_class, rocq_alias IntoIH]
class IntoIH [BI PROP] (φ : Prop) (P : PROP) (Q : outParam PROP) where
into_ih : φ → □ P ⊢ Q
export IntoIH (into_ih)

#rocq_ignore elim_inv_tc_opaque "No tc_opaque in Lean"
#rocq_ignore elim_modal_tc_opaque "No tc_opaque in Lean"
#rocq_ignore from_and_tc_opaque "No tc_opaque in Lean"
Expand Down
18 changes: 18 additions & 0 deletions Iris/Iris/ProofMode/Expr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,21 @@ def Hyps.addWithInfo {prop : Q(Type u)} (bi : Q(BI $prop))
addHypInfo nameRef nameTo ivar' prop ty (isBinder := true)
let hyps := Hyps.add bi nameTo ivar' p ty h
return ⟨ivar', hyps⟩

/--
Given hypothesis `hyps` representing `e` where every hypothesis exist in the
intuitionistic context, return the proof of `e ⊢ □ e`. Return `none` if
`hyps` contains hypotheses in the spatial context.
-/
def Hyps.buildIntuitionisticProof {u} {prop : Q(Type u)} {bi : Q(BI $prop)} {e}
(hyps : Hyps bi e) : Option Q($e ⊢ □ $e) :=
match hyps with
| .emp _ => some q(intuitionistically_emp.mpr)
| .hyp _ _ _ p _ _ =>
match matchBool p with
| .inl _ => some q(intuitionistically_idem.mpr)
| .inr _ => none
| .sep _ _ _ _ lhs rhs => do
let pfL ← buildIntuitionisticProof lhs
let pfR ← buildIntuitionisticProof rhs
some q((sep_mono $pfL $pfR).trans intuitionistically_sep_mpr)
48 changes: 48 additions & 0 deletions Iris/Iris/ProofMode/Instances.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ module

public import Iris.BI
public import Iris.ProofMode.Classes
public import Iris.ProofMode.ClassesMake
public import Iris.ProofMode.ModalityInstances
public import Iris.ProofMode.Expr
public import Iris.Std.TC
public import Iris.Std.RocqPorting

Expand Down Expand Up @@ -918,3 +920,49 @@ instance combineSepGives_persistently [BI PROP] (Q1 Q2 P : PROP)
[h : CombineSepGives Q1 Q2 P] :
CombineSepGives iprop(<pers> Q1) iprop(<pers> Q2) iprop(<pers> P) where
combine_sep_gives := persistently_sep_mpr.trans (persistently_mono h.combine_sep_gives)

@[rocq_alias into_ih_entails]
instance intoIH_entails [BI PROP] (P Q : PROP) : IntoIH (Entails' P Q) P Q where
into_ih := λ hpq => intuitionistically_elim.trans hpq

@[rocq_alias into_ih_forall]
instance (priority := default - 2) intoIH_forall [BI PROP] (φ : α → Prop) (P : PROP) (Φ : α → PROP)
[h : ∀ x, IntoIH (φ x) P (Φ x)] :
IntoIH (∀ x, φ x) P (BI.forall Φ) where
into_ih := by
intro hφ
apply forall_intro
intro x
exact (h x).into_ih (hφ x)

@[rocq_alias into_ih_impl]
instance (priority := default - 1) intoIH_imp [BI PROP] (φ ψ : Prop) (Δ P Q : PROP)
[h1 : MakeAffinely iprop(⌜φ⌝) P]
[h2 : IntoIH ψ Δ Q] :
IntoIH (φ → ψ) Δ iprop(P -∗ Q) where
into_ih := by
intro hImp
apply wand_intro
refine (sep_mono_right h1.make_affinely.mpr).trans ?_
refine persistent_and_affinely_sep_right.2.trans ?_
exact pure_elim_right (fun hφ => h2.into_ih (hImp hφ))

#rocq_ignore into_ih_Forall "List.Forall does not exist in the core Lean libraries, and ∀ x ∈ l, p x is used instead"

/-- Support for induction principles whose IH is guarded by `List.Forall₂`, e.g.
arising from mutual inductive types relating two lists element-wise. -/
@[rocq_alias into_ih_Forall2]
Comment thread
alvinylt marked this conversation as resolved.
instance (priority := default - 2) intoIH_listForall₂ [BI PROP] (φ : α → β → Prop) (l1 : List α) (l2 : List β)
(P : PROP) (Φ : α → β → PROP)
[h : ∀ x1 x2, IntoIH (φ x1 x2) P (Φ x1 x2)] :
IntoIH (List.Forall₂ φ l1 l2) P (bigSepL2 (fun _ x1 x2 => iprop(□ Φ x1 x2)) l1 l2) where
into_ih := by
intro h
induction h with
| nil => simp [bigSepL2, affine]
| cons x xs ih =>
simp [bigSepL2] at ⊢
apply intuitionistically_sep_idem.mpr.trans
refine sep_mono ?_ ?_
· exact intuitionistically_intro_intuitionistically ((h _ _).into_ih x)
· exact ih
2 changes: 1 addition & 1 deletion Iris/Iris/ProofMode/Porting.lean
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Iris.Std.RocqPorting
#rocq_concept proofmode "Tactics" "iCombine" ported "icombine"
#rocq_concept proofmode "Tactics" "iIntros (basic)" ported "iintro"
#rocq_concept proofmode "Tactics" "iIntros (all intro patterns)" missing ""
#rocq_concept proofmode "Tactics" "iInduction" missing ""
#rocq_concept proofmode "Tactics" "iInduction" ported "iinduction"
#rocq_concept proofmode "Tactics" "iLöb" ported "iloeb"
#rocq_concept proofmode "Tactics" "iAssert" ported "ihave _ : _"
#rocq_concept proofmode "Tactics" "iRewrite" ported "irewrite"
Expand Down
26 changes: 25 additions & 1 deletion Iris/Iris/ProofMode/ProofModeM.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2025 Michael Sammler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Sammler, Zongyuan Liu, Yunsong Yang
Authors: Michael Sammler, Zongyuan Liu, Yunsong Yang, Alvin Tang
-/
module

Expand Down Expand Up @@ -96,6 +96,30 @@ def addMVarGoal (m : MVarId) (name : Name := .anonymous) : ProofModeM Unit := do
m.setUserName name
modify ({goals := ·.goals.push m})

/--
Creates a new proof goal with the given hypotheses (`hyps`), conclusion
(`goal`). Run a sequence of tactics with this proof goal and push all
subgoals into the proof state.

The function returns:
1. the metavariable of the initial goal,
2. a Boolean value indicating whether the `firstTactic` solves all goals,
`false` if `firstTactic` is `none`.
-/
def addBIGoalRunTactics {prop : Q(Type u)} {bi : Q(BI $prop)}
{e} (hyps : Hyps bi e) (goal : Q($prop)) (name : Name := .anonymous)
(firstTactic : Option <| TSyntax `tactic)
(tacticSeq : TSyntax `Lean.Parser.Tactic.tacticSeq) :
ProofModeM (Q($e ⊢ $goal) × Bool) := do
let m ← mkBIGoal hyps goal name
-- Run `firstTactic`, if available
let subgoals ← firstTactic.elim (pure [m.mvarId!]) (evalTacticAt · m.mvarId!)
-- Run the user tactics on each newly generated goal after running `firstTactic`
let mut subgoals' := []
for s in subgoals do
subgoals' := subgoals'.append <| ← evalTacticAt tacticSeq s
pure (m, firstTactic.isSome && subgoals.isEmpty)

/-- Try to synthesize a typeclass instance, adding any created metavariables as proof mode goals. -/
def ProofModeM.trySynthInstanceQ (α : Q(Sort v)) : ProofModeM (Option Q($α)) := do
let LOption.some (e, mvars) ← ProofMode.trySynthInstance α | return none
Expand Down
1 change: 1 addition & 0 deletions Iris/Iris/ProofMode/Tactics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public meta import Iris.ProofMode.Tactics.ExFalso
public meta import Iris.ProofMode.Tactics.Exists
public meta import Iris.ProofMode.Tactics.Frame
public meta import Iris.ProofMode.Tactics.Have
public meta import Iris.ProofMode.Tactics.Induction
public meta import Iris.ProofMode.Tactics.Intro
public meta import Iris.ProofMode.Tactics.LeftRight
public meta import Iris.ProofMode.Tactics.Loeb
Expand Down
Loading