3 include "basics/logic.ma".
4 include "basics/types.ma".
5 include "basics/bool.ma".
6 include "arithmetics/nat.ma".
10 inductive Var : Type[0] ≝
13 (* Arithmetic expressions *)
15 inductive Aexp : Type[0] ≝
16 | Const :
\ 5a href="cic:/matita/arithmetics/nat/nat.ind(1,0,0)"
\ 6nat
\ 5/a
\ 6 → Aexp
17 | Aid :
\ 5span style="text-decoration: underline;"
\ 6\ 5/span
\ 6Var → Aexp
18 | Add : Aexp → Aexp → Aexp
19 | Sub : Aexp → Aexp → Aexp
20 | Mul : Aexp → Aexp → Aexp
21 | Div : Aexp → Aexp → Aexp
22 | Mod : Aexp → Aexp → Aexp
25 interpretation "Aexp plus" 'plus x y = (Add x y).
26 interpretation "Aexp minus" 'minus x y = (Sub x y).
27 interpretation "Aexp times" 'times x y = (Mul x y).
29 (* Boolean expressions *)
30 inductive Bexp : Type[0] ≝
34 | BAnd : Bexp → Bexp → Bexp
35 | BOr : Bexp → Bexp → Bexp
36 | Eq :
\ 5a href="cic:/matita/While/syntax/Aexp.ind(1,0,0)"
\ 6Aexp
\ 5/a
\ 6 →
\ 5a href="cic:/matita/While/syntax/Aexp.ind(1,0,0)"
\ 6Aexp
\ 5/a
\ 6 → Bexp
37 | LE :
\ 5a href="cic:/matita/While/syntax/Aexp.ind(1,0,0)"
\ 6Aexp
\ 5/a
\ 6 →
\ 5a href="cic:/matita/While/syntax/Aexp.ind(1,0,0)"
\ 6Aexp
\ 5/a
\ 6 → Bexp
40 interpretation "Bexp not" 'not x = (BNot x).
41 interpretation "Bexp and" 'and x y = (BAnd x y).
42 interpretation "Bexp or" 'or x y = (BOr x y).
43 interpretation "Bexp 'less or equal to'" 'leq x y = (LE x y).
46 inductive Cmd : Type[0] ≝
48 | Assign : Var →
\ 5a href="cic:/matita/While/syntax/Aexp.ind(1,0,0)"
\ 6Aexp
\ 5/a
\ 6 → Cmd
49 | Seq : Cmd → Cmd → Cmd
50 | If :
\ 5a href="cic:/matita/While/syntax/Bexp.ind(1,0,0)"
\ 6Bexp
\ 5/a
\ 6 → Cmd → Cmd → Cmd
51 | While :
\ 5a href="cic:/matita/While/syntax/Bexp.ind(1,0,0)"
\ 6Bexp
\ 5/a
\ 6 → Cmd → Cmd
54 notation "hvbox(c1 break ; c2)"
55 left associative with precedence 47 for @{Seq $c1 $c2}.
57 notation "hvbox(var break <- val)"
58 left associative with precedence 48 for @{Assign $var $val}.