From 8294ac2d254720b765c64eb1d3e180413b282816 Mon Sep 17 00:00:00 2001 From: Dan Frumin Date: Sat, 24 Mar 2018 15:58:40 +0100 Subject: [PATCH] Add quot and rem operations --- theories/F_mu_ref_conc/lang.v | 9 ++++++--- theories/F_mu_ref_conc/notation.v | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/theories/F_mu_ref_conc/lang.v b/theories/F_mu_ref_conc/lang.v index aaa6ec2..6468f88 100644 --- a/theories/F_mu_ref_conc/lang.v +++ b/theories/F_mu_ref_conc/lang.v @@ -11,7 +11,8 @@ Module lang. Instance loc_dec_eq : EqDecision loc := _. (** ** Expressions *) - Inductive binop := Mul | Add | Sub | Eq | Le | Lt | Xor. + Inductive binop := + Mul | Add | Sub | Quot | Rem | Eq | Le | Lt | Xor. Instance binop_dec_eq : EqDecision binop. Proof. solve_decision. Defined. @@ -108,6 +109,8 @@ Module lang. | Mul, LitV (Nat a), LitV (Nat b) => Some \$ LitV (Nat (a * b)) | Add, LitV (Nat a), LitV (Nat b) => Some \$ LitV (Nat (a + b)) | Sub, LitV (Nat a), LitV (Nat b) => Some \$ LitV (Nat (a - b)) + | Quot, LitV (Nat a), LitV (Nat b) => Some \$ LitV (Nat (a / b)%nat) + | Rem, LitV (Nat a), LitV (Nat b) => Some \$ LitV (Nat (a `mod` b)) | Eq, LitV (Nat a), LitV (Nat b) => Some \$ LitV (Bool (if decide (a = b) then true else false)) | Eq, LitV (Bool a), LitV (Bool b) => Some \$ LitV (Bool (eqb a b)) | Eq, LitV (Loc l1), LitV (Loc l2) => Some \$ LitV (Bool (if decide (l1 = l2) then true else false)) @@ -181,9 +184,9 @@ Module lang. Instance binop_countable : Countable binop. Proof. refine (inj_countable' (λ op, match op with - | Mul => 0 | Add => 1 | Sub => 2 | Eq => 3 | Le => 4 | Lt => 5 | Xor => 6 + | Mul => 0 | Add => 1 | Sub => 2 | Eq => 3 | Le => 4 | Lt => 5 | Xor => 6 | Quot => 7 | Rem => 8 end) (λ n, match n with - | 0 => Mul | 1 => Add | 2 => Sub | 3 => Eq | 4 => Le | 5 => Lt | _ => Xor + | 0 => Mul | 1 => Add | 2 => Sub | 3 => Eq | 4 => Le | 5 => Lt | 6 => Xor | 7 => Quot | _ => Rem end) _); by intros []. Qed. diff --git a/theories/F_mu_ref_conc/notation.v b/theories/F_mu_ref_conc/notation.v index 26a3b20..2041c28 100644 --- a/theories/F_mu_ref_conc/notation.v +++ b/theories/F_mu_ref_conc/notation.v @@ -61,6 +61,9 @@ Notation "e1 = e2" := (BinOp Eq e1%E e2%E) (at level 70) : expr_scope. Notation "e1 ⊕ e2" := (BinOp Xor e1%E e2%E) (at level 70) : expr_scope. Notation "¬ e" := (BinOp Xor e%E (Lit (Bool true))) (at level 75, right associativity) : expr_scope. +Notation "e1 / e2" := (BinOp Quot e1%E e2%E) : expr_scope. +Notation "e1 `mod` e2" := (BinOp Rem e1%E e2%E) : expr_scope. + (* The unicode ← is already part of the notation "_ ← _; _" for bind. *) Notation "e1 <- e2" := (Store e1%E e2%E) (at level 80) : expr_scope. -- 2.26.2