fix: Panic in partial instantiation
This commit is contained in:
parent
5c7bb288b2
commit
cf17428001
|
@ -14,18 +14,24 @@ def instantiatePartialDelayedMVars (e: Expr): MetaM Expr := do
|
||||||
Meta.transform e
|
Meta.transform e
|
||||||
(pre := fun e => e.withApp fun f args => do
|
(pre := fun e => e.withApp fun f args => do
|
||||||
if let .mvar mvarId := f then
|
if let .mvar mvarId := f then
|
||||||
|
if ← mvarId.isAssigned then
|
||||||
|
return .visit <| (← instantiateMVars e)
|
||||||
if let some decl ← getDelayedMVarAssignment? mvarId then
|
if let some decl ← getDelayedMVarAssignment? mvarId then
|
||||||
if args.size ≥ decl.fvars.size then
|
if args.size ≥ decl.fvars.size then
|
||||||
|
-- Do not use instantiateMVars here. Only one step of instantiation should happen.
|
||||||
let pending ← instantiateMVars (.mvar decl.mvarIdPending)
|
let pending ← instantiateMVars (.mvar decl.mvarIdPending)
|
||||||
if !pending.isMVar then
|
if !pending.isMVar then
|
||||||
return .visit <| (← Meta.mkLambdaFVars decl.fvars pending).beta args
|
let pending := pending.abstract decl.fvars
|
||||||
|
let pending := pending.instantiateRevRange 0 decl.fvars.size args
|
||||||
|
let pending := mkAppRange pending decl.fvars.size args.size args
|
||||||
|
return .visit <| pending
|
||||||
return .continue)
|
return .continue)
|
||||||
|
|
||||||
@[export pantograph_instantiate_all_meta_m]
|
@[export pantograph_instantiate_all_meta_m]
|
||||||
def instantiateAll (e: Expr): MetaM Expr := do
|
def instantiateAll (e: Expr): MetaM Expr := do
|
||||||
let e ← instantiateMVars e
|
let e ← instantiateMVars e
|
||||||
|
let e ← instantiatePartialDelayedMVars e
|
||||||
let e ← unfoldAuxLemmas e
|
let e ← unfoldAuxLemmas e
|
||||||
--let e ← instantiatePartialDelayedMVars e
|
|
||||||
return e
|
return e
|
||||||
|
|
||||||
structure DelayedMVarInvocation where
|
structure DelayedMVarInvocation where
|
||||||
|
|
|
@ -88,11 +88,11 @@ def test_tactic : IO LSpec.TestSeq :=
|
||||||
vars := #[{ name := "_uniq.10", userName := "x", isInaccessible? := .some false, type? := .some { pp? := .some "Prop" }}],
|
vars := #[{ name := "_uniq.10", userName := "x", isInaccessible? := .some false, type? := .some { pp? := .some "Prop" }}],
|
||||||
}
|
}
|
||||||
let goal2: Protocol.Goal := {
|
let goal2: Protocol.Goal := {
|
||||||
name := "_uniq.14",
|
name := "_uniq.17",
|
||||||
target := { pp? := .some "x ∨ y → y ∨ x" },
|
target := { pp? := .some "x ∨ y → y ∨ x" },
|
||||||
vars := #[
|
vars := #[
|
||||||
{ name := "_uniq.10", userName := "x", isInaccessible? := .some false, type? := .some { pp? := .some "Prop" }},
|
{ name := "_uniq.10", userName := "x", isInaccessible? := .some false, type? := .some { pp? := .some "Prop" }},
|
||||||
{ name := "_uniq.13", userName := "y", isInaccessible? := .some false, type? := .some { pp? := .some "Prop" }}
|
{ name := "_uniq.16", userName := "y", isInaccessible? := .some false, type? := .some { pp? := .some "Prop" }}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
subroutine_runner [
|
subroutine_runner [
|
||||||
|
|
|
@ -771,7 +771,7 @@ def test_nat_zero_add_alt: TestM Unit := do
|
||||||
| other => do
|
| other => do
|
||||||
addTest $ assertUnreachable $ other.toString
|
addTest $ assertUnreachable $ other.toString
|
||||||
return ()
|
return ()
|
||||||
let (eqL, eqR, eqT) := ("_uniq.85", "_uniq.86", "_uniq.84")
|
let (eqL, eqR, eqT) := ("_uniq.88", "_uniq.89", "_uniq.87")
|
||||||
addTest $ LSpec.check tactic $ state3m2.goals.map (·.name.toString) = [eqL, eqR, eqT]
|
addTest $ LSpec.check tactic $ state3m2.goals.map (·.name.toString) = [eqL, eqR, eqT]
|
||||||
let [_motive, _major, _step, conduit] := state2.goals | panic! "Goals conflict"
|
let [_motive, _major, _step, conduit] := state2.goals | panic! "Goals conflict"
|
||||||
let state2b ← match state3m2.resume [conduit] with
|
let state2b ← match state3m2.resume [conduit] with
|
||||||
|
@ -789,8 +789,8 @@ def test_nat_zero_add_alt: TestM Unit := do
|
||||||
name := "_uniq.70",
|
name := "_uniq.70",
|
||||||
userName? := .some "conduit",
|
userName? := .some "conduit",
|
||||||
target := {
|
target := {
|
||||||
pp? := .some "?m.79 ?m.68 = (n + 0 = n)",
|
pp? := .some "(?motive.a = ?motive.a) = (n + 0 = n)",
|
||||||
sexp? := .some s!"((:c Eq) (:sort 0) (:subst ((:c Eq) (:mv {eqT}) (:mv {eqL}) (:mv {eqR})) (:fv {fvN}) (:mv {major})) ((:c Eq) (:c Nat) ({cNatAdd} (:fv {fvN}) {cNat0}) (:fv {fvN})))",
|
sexp? := .some s!"((:c Eq) (:sort 0) ((:c Eq) (:mv {eqT}) (:mv {eqL}) (:mv {eqR})) ((:c Eq) (:c Nat) ({cNatAdd} (:fv {fvN}) {cNat0}) (:fv {fvN})))",
|
||||||
},
|
},
|
||||||
vars := #[{
|
vars := #[{
|
||||||
name := fvN,
|
name := fvN,
|
||||||
|
|
Loading…
Reference in New Issue