File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,15 +347,11 @@ It reduces terms by unfolding definitions using their defining equations and
347347applying matcher equations. The unfolding is propositional, so `cbv` also works
348348with functions defined via well-founded recursion or partial fixpoints.
349349
350- `cbv` reduces the goal type (and optionally hypothesis types) using call-by-value
351- evaluation. For equation goals (`lhs = rhs`), `cbv` automatically attempts `refl`
352- after reduction to close the goal.
350+ `cbv` reduces the goal target using call-by-value evaluation. For equation goals
351+ (`lhs = rhs`), `cbv` automatically attempts `refl` after reduction to close the goal.
353352
354- `cbv` supports the standard `at` location syntax:
355- - `cbv` — reduce the goal target
356- - `cbv at h` — reduce hypothesis `h`
357- - `cbv at h |-` — reduce hypothesis `h` and the goal target
358- - `cbv at *` — reduce all non-dependent propositional hypotheses and the goal target
353+ Unlike the standalone `cbv` tactic, this variant does not support the `at` location
354+ syntax: in `sym =>` mode it only reduces the goal target.
359355
360356`cbv` is not a finishing tactic in general: it may leave a new (simpler) goal.
361357
@@ -365,6 +361,6 @@ generator.
365361
366362This is a variant of `cbv` that only works in `sym =>` mode.
367363-/
368- syntax (name := symCbv) " cbv" (location)? : grind
364+ syntax (name := symCbv) " cbv" : grind
369365end Grind
370366end Lean.Parser.Tactic
Original file line number Diff line number Diff line change @@ -295,22 +295,11 @@ def elabDSimpVariant (variantName : Name) (args : DSimpArgs) : GrindTacticM (Sym
295295 goal.mvarId.assign mvarNew
296296 replaceMainGoal [{ goal with mvarId := mvarNew.mvarId! }]
297297
298- /-- Resolve the hypothesis identifiers of a `cbv at` location to `FVarId`s. -/
299- private def resolveLocFVarIds (hyps : Array Syntax) : GrindTacticM (Array FVarId) := do
300- let lctx ← getLCtx
301- hyps.mapM fun hyp => do
302- let some decl := lctx.findFromUserName? hyp.getId
303- | throwError "unknown hypothesis `{hyp}`"
304- return decl.fvarId
305-
306- @ [builtin_grind_tactic Parser.Tactic.Grind.symCbv] def evalSymCbv : GrindTactic := fun stx => withMainContext do
298+ @ [builtin_grind_tactic Parser.Tactic.Grind.symCbv] def evalSymCbv : GrindTactic := fun _ => withMainContext do
307299 ensureSym
308300 let goal ← getMainGoal
309- let (fvarIds, simplifyTarget) ← match expandOptLocation stx[1 ] with
310- | .targets hyps simplifyTarget => pure (← resolveLocFVarIds hyps, simplifyTarget)
311- | .wildcard => pure (← goal.mvarId.getNondepPropHyps, true )
312301 let result ← liftGrindM <|
313- Lean.Meta.Tactic.Cbv.cbvGoalCore goal.mvarId simplifyTarget fvarIds
302+ Lean.Meta.Tactic.Cbv.cbvGoalCore goal.mvarId
314303 match result with
315304 | none => replaceMainGoal []
316305 | some mvarId => replaceMainGoal [{ goal with mvarId }]
Original file line number Diff line number Diff line change @@ -205,7 +205,7 @@ def handleProj : Simproc := fun e => do
205205 let res ← simp struct
206206 match res with
207207 | .rfl _ cd =>
208- let some reduced ← withCbvOpaqueGuard <| reduceProj? <| .proj typeName idx struct | do
208+ let some reduced ← withCbvOpaqueGuard <| withDefault <| reduceProj? <| .proj typeName idx struct | do
209209 return .rfl (done := true ) cd
210210
211211 let reduced ← Sym.share reduced
@@ -223,7 +223,7 @@ def handleProj : Simproc := fun e => do
223223 return .step (← Lean.Expr.updateProjS! e e') newProof cd
224224 else
225225 -- If the type of the projection function is dependent, we first try to reduce the projection
226- let reduced ← withCbvOpaqueGuard <| reduceProj? e
226+ let reduced ← withCbvOpaqueGuard <| withDefault <| reduceProj? e
227227 match reduced with
228228 | .some reduced =>
229229 let reduced ← Sym.share reduced
Original file line number Diff line number Diff line change @@ -9,17 +9,22 @@ example (h : a = 8) : Nat.succ 7 = a := by
99 cbv
1010 exact h.symm
1111
12- example (h : Nat.succ 7 = a) : 8 = a := by
13- sym =>
14- cbv at h
15- exact h
16-
17- example (h : Nat.succ 7 = a) : Nat.succ 7 = a := by
18- sym =>
19- cbv at h ⊢
20- exact h
12+ example :
13+ have v :=
14+ BitVec.ofNat 64 ((BitVec.ofNat ( 64 - 0 ) ((BitVec.setWidth 64 (Int64.toBitVec 2 )).toNat >>> 0 )).toNat >>> 0 ) - 1 ;
15+ have v_1 := BitVec.ofNat 64 ((BitVec.ofNat ( 64 - 0 ) (v.toNat >>> 0 )).toNat >>> 0 ) - 1 ;
16+ v ≠ v_1
17+ := by
18+ cbv
19+ intro hyp
20+ trivial
2121
22- example (h : Nat.succ 7 = a) : Nat.succ 7 = a := by
22+ example :
23+ have v :=
24+ BitVec.ofNat 64 ((BitVec.ofNat (64 - 0 ) ((BitVec.setWidth 64 (Int64.toBitVec 2 )).toNat >>> 0 )).toNat >>> 0 ) - 1 ;
25+ have v_1 := BitVec.ofNat 64 ((BitVec.ofNat (64 - 0 ) (v.toNat >>> 0 )).toNat >>> 0 ) - 1 ;
26+ v ≠ v_1
27+ := by
2328 sym =>
24- cbv at *
25- exact h
29+ cbv
30+ intro hyp
You can’t perform that action at this time.
0 commit comments