File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -143,3 +143,30 @@ elab "list_eg" : term => do
143
143
#eval list_eg
144
144
145
145
#check mkSort
146
+
147
+ #check Prod
148
+
149
+ def prodExpr? (e: Expr) :
150
+ MetaM <|Option (Expr × Expr) := do
151
+ let u ← mkFreshLevelMVar
152
+ let v ← mkFreshLevelMVar
153
+ let α ← mkFreshExprMVar (mkSort <| Level.succ u)
154
+ let β ← mkFreshExprMVar (mkSort <| Level.succ v)
155
+ let prod ← mkAppM ``Prod #[α, β]
156
+ if ← isDefEq e prod then
157
+ return some (α, β)
158
+ else
159
+ return none
160
+
161
+
162
+ elab "#prodExpr" "[" e:term "]" : command =>
163
+ Command.liftTermElabM do
164
+ let e ← elabTerm e none
165
+ match ← prodExpr? e with
166
+ | some (α, β) =>
167
+ logInfo m!"{α} × {β}"
168
+ logInfo m!"{α} has type: {← inferType α}"
169
+ logInfo m!"{β} has type: {← inferType β}"
170
+ | none => logInfo "Not a PProd expression"
171
+
172
+ #prodExpr [Nat × (Nat → Type )]
You can’t perform that action at this time.
0 commit comments