mirror of
https://github.com/supleed2/ELEC70056-HSV-CW1.git
synced 2024-11-14 12:15:48 +00:00
21 lines
496 B
Plaintext
21 lines
496 B
Plaintext
|
theory HSV_tasks_2019 imports Main begin
|
||
|
|
||
|
datatype "circuit" =
|
||
|
NOT "circuit"
|
||
|
| AND "circuit" "circuit"
|
||
|
| OR "circuit" "circuit"
|
||
|
| TRUE
|
||
|
| FALSE
|
||
|
| INPUT "int"
|
||
|
|
||
|
section \<open>Starting point for Task 8\<close>
|
||
|
|
||
|
text \<open>The following function calculates the area of a circuit (i.e. number of gates).\<close>
|
||
|
|
||
|
fun area :: "circuit \<Rightarrow> nat" where
|
||
|
"area (NOT c) = 1 + area c"
|
||
|
| "area (AND c1 c2) = 1 + area c1 + area c2"
|
||
|
| "area (OR c1 c2) = 1 + area c1 + area c2"
|
||
|
| "area _ = 0"
|
||
|
|
||
|
end
|