You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lean/main/04_metam.lean
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ assigns `?b := f a`. Assigned metavariables are not considered open goals, so
127
127
the only goal that remains is `?m3`.
128
128
129
129
Now the third `apply` comes in. Since `?b` has been assigned, the target of
130
-
`?m3` is now `f (f a) = a`. Again, the application of `h` succeeds and the
130
+
`?m3` is now `f a = a`. Again, the application of `h` succeeds and the
131
131
tactic assigns `?m3 := h a`.
132
132
133
133
At this point, all metavariables are assigned as follows:
@@ -1235,9 +1235,9 @@ Notice that changing the type of the metavariable from `Nat` to, for example, `S
1235
1235
-- Instantiate `mvar1`, which should result in expression `2 + ?mvar2 + 1`
1236
1236
...
1237
1237
```
1238
-
4. [**Metavariables**] Consider the theorem `red`, and tactic `explore` below.
1239
-
**a)** What would be the `type` and `userName` of metavariable `mvarId`?
1240
-
**b)** What would be the `type`s and `userName`s of all local declarations in this metavariable's local context?
1238
+
4. [**Metavariables**] Consider the theorem `red`, and tactic `explore` below.
1239
+
**a)** What would be the `type` and `userName` of metavariable `mvarId`?
1240
+
**b)** What would be the `type`s and `userName`s of all local declarations in this metavariable's local context?
1241
1241
Print them all out.
1242
1242
1243
1243
```lean
@@ -1256,17 +1256,17 @@ Notice that changing the type of the metavariable from `Nat` to, for example, `S
1256
1256
sorry
1257
1257
```
1258
1258
5. [**Metavariables**] Write a tactic `solve` that proves the theorem `red`.
1259
-
6. [**Computation**] What is the normal form of the following expressions:
1260
-
**a)** `fun x => x` of type `Bool → Bool`
1261
-
**b)** `(fun x => x) ((true && false) || true)` of type `Bool`
1259
+
6. [**Computation**] What is the normal form of the following expressions:
1260
+
**a)** `fun x => x` of type `Bool → Bool`
1261
+
**b)** `(fun x => x) ((true && false) || true)` of type `Bool`
1262
1262
**c)** `800 + 2` of type `Nat`
1263
1263
7. [**Computation**] Show that `1` created with `Expr.lit (Lean.Literal.natVal 1)` is definitionally equal to an expression created with `Expr.app (Expr.const ``Nat.succ []) (Expr.const ``Nat.zero [])`.
1264
-
8. [**Computation**] Determine whether the following expressions are definitionally equal. If `Lean.Meta.isDefEq` succeeds, and it leads to metavariable assignment, write down the assignments.
1265
-
**a)** `5 =?= (fun x => 5) ((fun y : Nat → Nat => y) (fun z : Nat => z))`
1266
-
**b)** `2 + 1 =?= 1 + 2`
1267
-
**c)** `?a =?= 2`, where `?a` has a type `String`
1268
-
**d)** `?a + Int =?= "hi" + ?b`, where `?a` and `?b` don't have a type
1269
-
**e)** `2 + ?a =?= 3`
1264
+
8. [**Computation**] Determine whether the following expressions are definitionally equal. If `Lean.Meta.isDefEq` succeeds, and it leads to metavariable assignment, write down the assignments.
1265
+
**a)** `5 =?= (fun x => 5) ((fun y : Nat → Nat => y) (fun z : Nat => z))`
1266
+
**b)** `2 + 1 =?= 1 + 2`
1267
+
**c)** `?a =?= 2`, where `?a` has a type `String`
1268
+
**d)** `?a + Int =?= "hi" + ?b`, where `?a` and `?b` don't have a type
1269
+
**e)** `2 + ?a =?= 3`
1270
1270
**f)** `2 + ?a =?= 2 + 1`
1271
1271
9. [**Computation**] Write down what you expect the following code to output.
1272
1272
@@ -1300,14 +1300,14 @@ Notice that changing the type of the metavariable from `Nat` to, for example, `S
1300
1300
let reducedExpr ← Meta.reduce constantExpr
1301
1301
dbg_trace (← ppExpr reducedExpr) -- ...
1302
1302
```
1303
-
10. [**Constructing Expressions**] Create expression `fun x, 1 + x` in two ways:
1304
-
**a)** not idiomatically, with loose bound variables
1305
-
**b)** idiomatically.
1303
+
10. [**Constructing Expressions**] Create expression `fun x, 1 + x` in two ways:
1304
+
**a)** not idiomatically, with loose bound variables
1305
+
**b)** idiomatically.
1306
1306
In what version can you use `Lean.mkAppN`? In what version can you use `Lean.Meta.mkAppM`?
0 commit comments