Skip to content

Commit

Permalink
chore: use double-backtick
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner committed Nov 1, 2022
1 parent a04dac6 commit 63444c4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Mathport/Binary/Number.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ These functions mimic the ones in lean3/src/library/num.cpp
-/
import Lean
import Mathport.Binary.Basic
import Mathlib.Init.ZeroOne

namespace Mathport.Binary

open Lean

partial def isConcreteNat? (e : Expr) : Option Nat := do
if e.isConstOf `Nat.zero then
if e.isConstOf ``Nat.zero then
some 0
else if e.isAppOfArity `Nat.succ 1 then
else if e.isAppOfArity ``Nat.succ 1 then
let n ← isConcreteNat? e.appArg!
some (n+1)
else
Expand All @@ -31,26 +32,26 @@ structure NumInfo where
deriving Inhabited

partial def isNumber? (e : Expr) : Option NumInfo := do
if e.isAppOfArity `Zero.zero 2 then pure {
if e.isAppOfArity ``Zero.zero 2 then pure {
number := 0,
level := e.getAppFn.constLevels!.head!,
type := e.getArg! 0
hasZero? := e.getArg! 1
}
else if e.isAppOfArity `One.one 2 then pure {
else if e.isAppOfArity ``One.one 2 then pure {
number := 1,
level := e.getAppFn.constLevels!.head!,
type := e.getArg! 0,
hasOne? := e.getArg! 1
}
else if e.isAppOfArity `bit0 3 then
else if e.isAppOfArity ``bit0 3 then
-- TODO: may need to check if these instances are def-eq
-- (I am hoping that mathlib does not produce terms in which they are not)
let info ← isNumber? $ e.getArg! 2
pure { info with
number := info.number * 2,
hasAdd? := info.hasAdd? <|> e.getArg! 1 }
else if e.isAppOfArity `bit1 4 then
else if e.isAppOfArity ``bit1 4 then
let info ← isNumber? $ e.getArg! 3
pure { info with
number := info.number * 2 + 1,
Expand All @@ -67,7 +68,7 @@ def translateNumbers (e : Expr) : MetaM Expr := Meta.transform e (pre := core) w
| some { number := n, level, type, .. } =>
-- TODO: we will want to avoid wrapping "normal" Nat numbers
-- (current workaround is for the OfNat instances to `no_index` the numbers)
let inst := mkAppN (mkConst `OfNat.mk [level]) #[type, mkRawNatLit n, e]
TransformStep.done $ mkAppN (mkConst `OfNat.ofNat [level]) #[type, mkRawNatLit n, inst]
let inst := mkAppN (mkConst ``OfNat.mk [level]) #[type, mkRawNatLit n, e]
TransformStep.done $ mkAppN (mkConst ``OfNat.ofNat [level]) #[type, mkRawNatLit n, inst]

end Mathport.Binary

0 comments on commit 63444c4

Please sign in to comment.