2014-08-01 00:48:51 +00:00
|
|
|
----------------------------------------------------------------------------------------------------
|
2014-07-02 15:08:35 +00:00
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
-- Author: Leonardo de Moura
|
2014-08-01 00:48:51 +00:00
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import logic.classes.inhabited
|
|
|
|
|
2014-07-02 15:08:35 +00:00
|
|
|
namespace num
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-07-02 15:08:35 +00:00
|
|
|
-- pos_num and num are two auxiliary datatypes used when parsing numerals such as 13, 0, 26.
|
|
|
|
-- The parser will generate the terms (pos (bit1 (bit1 (bit0 one)))), zero, and (pos (bit0 (bit1 (bit1 one)))).
|
|
|
|
-- This representation can be coerced in whatever we want (e.g., naturals, integers, reals, etc).
|
|
|
|
inductive pos_num : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
one : pos_num,
|
|
|
|
bit1 : pos_num → pos_num,
|
|
|
|
bit0 : pos_num → pos_num
|
2014-07-02 15:08:35 +00:00
|
|
|
|
|
|
|
inductive num : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
zero : num,
|
|
|
|
pos : pos_num → num
|
2014-07-02 15:08:35 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
theorem inhabited_pos_num [instance] : inhabited pos_num :=
|
2014-08-20 02:32:44 +00:00
|
|
|
inhabited_mk one
|
2014-07-04 21:25:44 +00:00
|
|
|
|
2014-08-20 22:49:44 +00:00
|
|
|
theorem num_inhabited [instance] : inhabited num :=
|
2014-08-20 02:32:44 +00:00
|
|
|
inhabited_mk zero
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-20 02:32:44 +00:00
|
|
|
end num
|