bump to v4.6.0

This commit is contained in:
Jon Eugster
2024-02-29 17:19:01 +01:00
parent 26d8cf5395
commit 381a729f3e
10 changed files with 92 additions and 92 deletions

View File

@@ -30,6 +30,6 @@ Statement add_comm (a b : ) : a + b = b + a := by
rfl
-- Adding this instance to make `ac_rfl` work.
instance : Lean.IsCommutative (α := ) (· + ·) := add_comm
instance : Std.Commutative (α := ) (· + ·) := add_comm
TheoremTab "+"

View File

@@ -43,7 +43,7 @@ Statement add_assoc (a b c : ) : a + b + c = a + (b + c) := by
rfl
-- Adding this instance to make `ac_rfl` work.
instance : Lean.IsAssociative (α := ) (· + ·) := add_assoc
instance : Std.Associative (α := ) (· + ·) := add_assoc
TheoremTab "+"

View File

@@ -1,16 +0,0 @@
import Lean
-- Note: to get `ac_rfl` working (which is in core), we just
-- need the two instances below in the files where
-- `add_assoc` and `add_comm` are proven.
-- This file is only for demonstration purpose.
import Game.Levels.Addition.Level_2 -- defines `MyNat.add_assoc`
import Game.Levels.Addition.Level_4 -- defines `MyNat.add_comm`
instance : Lean.IsAssociative (α := ) (·+·) := MyNat.add_assoc
instance : Lean.IsCommutative (α := ) (·+·) := MyNat.add_comm
example (a b c : ) : c + (b + a) = (a + b) + c := by
ac_rfl

View File

@@ -31,16 +31,14 @@ Usage: `cases n with d` if `n : `; `cases h with h1 h2` if `h : P Q`; `ca
-/
elab (name := cases) "cases " tgts:(Parser.Tactic.casesTarget,+) usingArg:((" using " ident)?)
withArg:((" with" (ppSpace colGt binderIdent)+)?) : tactic => do
let targets elabCasesTargets tgts.1.getSepArgs
let (targets, toTag) elabCasesTargets tgts.1.getSepArgs
let g :: gs getUnsolvedGoals | throwNoGoalsToBeSolved
g.withContext do
let elimInfo getElimNameInfo usingArg targets (induction := false)
-- Edit: If `elimInfo.name` is `MyNat.casesOn` we want to use `MyNat.casesOn'` instead.
-- TODO: This seems extremely hacky. Especially that we need to get the `elimInfo` twice.
-- Please improve this.
let elimInfo match elimInfo.name with
| `MyNat.casesOn =>
-- Edit: If `MyNat.casesOn` is used, we want to use `MyNat.casesOn` instead.
let elimInfo match elimInfo.elimExpr.getAppFn.constName? with
| some `MyNat.casesOn =>
let modifiedUsingArgs : TSyntax Name.anonymous :=
match usingArg.raw with
| .node info kind #[] =>
@@ -62,7 +60,9 @@ elab (name := cases) "cases " tgts:(Parser.Tactic.casesTarget,+) usingArg:((" us
ElimApp.setMotiveArg g motive.mvarId! targetsNew
g.assign result.elimApp
let subgoals ElimApp.evalNames elimInfo result.alts withArg
(numEqs := targets.size) (toClear := targetsNew)
(numEqs := targets.size) (toClear := targetsNew) (toTag := toTag)
setGoals <| subgoals.toList ++ gs
end MyNat

View File

@@ -17,6 +17,10 @@ to support the lean3-style `with` keyword.
This is mainly copied and modified from the mathlib-tactic `induction'`.
-/
/--
Custom induction principial for the tactics `induction`.
Used to show `0` instead of `MyNat.zero` in the base case.
-/
def rec' {P : Prop} (zero : P 0)
(succ : (n : ) (n_ih : P n) P (succ n)) (t : ) : P t := by
induction t with
@@ -44,15 +48,14 @@ elab (name := MyNat.induction) "induction " tgts:(Parser.Tactic.casesTarget,+)
usingArg:((" using " ident)?)
withArg:((" with" (ppSpace colGt binderIdent)+)?)
genArg:((" generalizing" (ppSpace colGt ident)+)?) : tactic => do
let targets elabCasesTargets tgts.1.getSepArgs
let (targets, toTag) elabCasesTargets tgts.1.getSepArgs
let g :: gs getUnsolvedGoals | throwNoGoalsToBeSolved
g.withContext do
let elimInfo getElimNameInfo usingArg targets (induction := true)
-- Edit: If `elimInfo.name` is `MyNat.rec` we want to use `MyNat.rec'` instead.
-- TODO: This seems extremely hacky. Especially that we need to get the `elimInfo` twice.
-- Please improve this.
let elimInfo match elimInfo.name with
| `MyNat.rec =>
-- Edit: If `MyNat.rec` is used, we want to use `MyNat.rec'` instead.
let elimInfo match elimInfo.elimExpr.getAppFn.constName? with
| some `MyNat.rec =>
let modifiedUsingArgs : TSyntax Name.anonymous :=
match usingArg.raw with
| .node info kind #[] =>
@@ -72,11 +75,11 @@ elab (name := MyNat.induction) "induction " tgts:(Parser.Tactic.casesTarget,+)
let mut s getFVarSetToGeneralize targets forbidden
for v in genArgs do
if forbidden.contains v then
throwError ("variable cannot be generalized " ++
"because target depends on it{indentExpr (mkFVar v)}")
throwError "variable cannot be generalized \
because target depends on it{indentExpr (mkFVar v)}"
if s.contains v then
throwError ("unnecessary 'generalizing' argument, " ++
"variable '{mkFVar v}' is generalized automatically")
throwError "unnecessary 'generalizing' argument, \
variable '{mkFVar v}' is generalized automatically"
s := s.insert v
let (fvarIds, g) g.revert ( sortFVarIds s.toArray)
g.withContext do
@@ -85,5 +88,5 @@ elab (name := MyNat.induction) "induction " tgts:(Parser.Tactic.casesTarget,+)
ElimApp.setMotiveArg g elimArgs[elimInfo.motivePos]!.mvarId! targetFVarIds
g.assign result.elimApp
let subgoals ElimApp.evalNames elimInfo result.alts withArg
(numGeneralized := fvarIds.size) (toClear := targetFVarIds)
(generalized := fvarIds) (toClear := targetFVarIds) (toTag := toTag)
setGoals <| (subgoals ++ result.others).toList ++ gs

View File

@@ -1,20 +0,0 @@
import Game.Levels.LessOrEqual
namespace MyNat
example (P Q : Prop) (h : P Q) : False := by
cases h with hp hq
· sorry -- hp : P
· sorry -- hq : Q
example (a b : ) (h : a b) : False := by
cases h with c hc
-- hc: b = a + c
sorry
-- not working yet
example (a : ) : a = a := by
cases a with d
-- get MyNat.zero because we used rec not rec' :-(
· sorry
· sorry