Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
lecopivo committed Mar 29, 2024
1 parent 5b0397e commit 2766331
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
58 changes: 29 additions & 29 deletions SciLean/Data/ArrayType/Notation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,35 @@ def unexpandArrayToArrayType : Lean.PrettyPrinter.Unexpander

namespace ArrayType.PowerNotation

class SHPow {α : Sort u} {β : Sort v} {γ : outParam (Sort w)} (a :α) (b : β) (c : outParam γ)
def SHPow.pow {α β γ} (a : α) (b : β) {c : γ} [SHPow a b c] := c

instance {Cont Idx Elem} [ArrayTypeNotation Cont Idx Elem] : SHPow Elem Idx (arrayTypeCont Idx Elem) := ⟨⟩
instance {α β γ} (x : α) (y : β) [HPow α β γ] : SHPow x y (HPow.hPow x y):= ⟨⟩
open Lean Elab Term Meta in
elab:40 (priority:=high) x:term:41 " ^ " y:term:42 : term => withFreshMacroScope do
let x ← elabTerm (← `(SHPow.pow $x $y)) none
return x.getArg! 5

/- #check K ^ (κ×ι)
#eval 2 ^ 3
-/

/- open Lean Elab Term in
elab:40 (priority:=high) x:term:41 " ^ " y:term:42 : term =>
try
let y ← elabTerm y none
let x ← elabTerm x none
let z ← Meta.mkAppOptM ``arrayTypeCont #[y,x,none,none]
return z
catch _ => do
return ← elabTerm (← `(HPow.hPow $x $y)) none
-/
@[app_unexpander arrayTypeCont] def unexpandArrayTypeCont : Lean.PrettyPrinter.Unexpander
| `($(_) $I $X) =>
`($X ^ $I)
| _ => throw ()
-- class SHPow {α : Sort u} {β : Sort v} {γ : outParam (Sort w)} (a :α) (b : β) (c : outParam γ)
-- def SHPow.pow {α β γ} (a : α) (b : β) {c : γ} [SHPow a b c] := c

-- instance {Cont Idx Elem} [ArrayTypeNotation Cont Idx Elem] : SHPow Elem Idx (arrayTypeCont Idx Elem) := ⟨⟩
-- instance {α β γ} (x : α) (y : β) [HPow α β γ] : SHPow x y (HPow.hPow x y):= ⟨⟩
-- open Lean Elab Term Meta in
-- elab:40 (priority:=high) x:term:41 " ^ " y:term:42 : term => withFreshMacroScope do
-- let x ← elabTerm (← `(SHPow.pow $x $y)) none
-- return x.getArg! 5

-- /- #check K ^ (κ×ι)
-- #eval 2 ^ 3

-- -/

-- /- open Lean Elab Term in
-- elab:40 (priority:=high) x:term:41 " ^ " y:term:42 : term =>
-- try
-- let y ← elabTerm y none
-- let x ← elabTerm x none
-- let z ← Meta.mkAppOptM ``arrayTypeCont #[y,x,none,none]
-- return z
-- catch _ => do
-- return ← elabTerm (← `(HPow.hPow $x $y)) none
-- -/
-- @[app_unexpander arrayTypeCont] def unexpandArrayTypeCont : Lean.PrettyPrinter.Unexpander
-- | `($(_) $I $X) =>
-- `($X ^ $I)
-- | _ => throw ()


-- Notation: Float^[10,20] --
Expand Down
5 changes: 5 additions & 0 deletions SciLean/Tactic/DeduceBy.lean
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ partial def deduceByTactic : Tactic
let goal ← getMainGoal
let .some (_,lhs,rhs) := Expr.eq? (← goal.getType) | throwError "expected `?m = e`, got {← ppExpr (← goal.getType)}"

if ¬lhs.hasMVar ∨ ¬rhs.hasMVar then
let prf ← elabTerm (← `(by (conv => ($t;$t)); try simp)) (← goal.getType)
goal.assign prf
return ()

-- if ¬lhs.isMVar then
-- throwError "lhs is not mvar"

Expand Down

0 comments on commit 2766331

Please sign in to comment.